Skip to content

Commit 094c907

Browse files
committed
fix #1261
1 parent 115b3ae commit 094c907

File tree

5 files changed

+16
-4
lines changed

5 files changed

+16
-4
lines changed

packages/react-bootstrap-table2-paginator/src/pagination.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import Const from './const';
1313
class Pagination extends pageResolver(Component) {
1414
render() {
1515
const {
16+
tableId,
1617
currPage,
1718
pageStartIndex,
1819
showTotal,
@@ -43,6 +44,7 @@ class Pagination extends pageResolver(Component) {
4344
<div className="row react-bootstrap-table-pagination">
4445
<div className="col-md-6 col-xs-6 col-sm-6 col-lg-6">
4546
<SizePerPageDropdownWithAdapter
47+
tableId={ tableId }
4648
sizePerPageList={ sizePerPageList }
4749
currSizePerPage={ currSizePerPage }
4850
hideSizePerPage={ hideSizePerPage }

packages/react-bootstrap-table2-paginator/src/size-per-page-dropdown-adapter.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const sizePerPageDropdownAdapter = WrappedComponent =>
3030

3131
render() {
3232
const {
33+
tableId,
3334
sizePerPageList,
3435
currSizePerPage,
3536
hideSizePerPage,
@@ -56,6 +57,7 @@ const sizePerPageDropdownAdapter = WrappedComponent =>
5657
onClick={ this.toggleDropDown }
5758
onBlur={ this.closeDropDown }
5859
open={ open }
60+
tableId={ tableId }
5961
/>
6062
);
6163
}

packages/react-bootstrap-table2-paginator/src/size-per-page-dropdown.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const sizePerPageDefaultClass = 'react-bs-table-sizePerPage-dropdown';
99
const SizePerPageDropDown = (props) => {
1010
const {
1111
open,
12+
tableId,
1213
hidden,
1314
onClick,
1415
onBlur,
@@ -30,6 +31,8 @@ const SizePerPageDropDown = (props) => {
3031
className,
3132
);
3233

34+
const id = tableId ? `${tableId}-pageDropDown` : 'pageDropDown';
35+
3336
return (
3437
<BootstrapContext.Consumer>
3538
{
@@ -39,7 +42,8 @@ const SizePerPageDropDown = (props) => {
3942
className={ dropdownClasses }
4043
>
4144
<button
42-
id="pageDropDown"
45+
id={ id }
46+
type="button"
4347
className={ `btn ${btnContextual} dropdown-toggle` }
4448
data-toggle="dropdown"
4549
aria-expanded={ open }
@@ -59,7 +63,7 @@ const SizePerPageDropDown = (props) => {
5963
<ul
6064
className={ `dropdown-menu ${openClass}` }
6165
role="menu"
62-
aria-labelledby="pageDropDown"
66+
aria-labelledby={ id }
6367
>
6468
{
6569
options.map((option) => {
@@ -93,6 +97,7 @@ SizePerPageDropDown.propTypes = {
9397
onClick: PropTypes.func.isRequired,
9498
onBlur: PropTypes.func.isRequired,
9599
onSizePerPageChange: PropTypes.func.isRequired,
100+
tableId: PropTypes.string,
96101
open: PropTypes.bool,
97102
hidden: PropTypes.bool,
98103
btnContextual: PropTypes.string,
@@ -106,7 +111,8 @@ SizePerPageDropDown.defaultProps = {
106111
btnContextual: 'btn-default btn-secondary',
107112
variation: 'dropdown',
108113
className: '',
109-
optionRenderer: null
114+
optionRenderer: null,
115+
tableId: null
110116
};
111117

112118

packages/react-bootstrap-table2-paginator/src/state-context.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class StateProvider extends React.Component {
4747
}
4848

4949
getPaginationProps = () => {
50-
const { pagination: { options }, bootstrap4 } = this.props;
50+
const { pagination: { options }, bootstrap4, tableId } = this.props;
5151
const { currPage, currSizePerPage, dataSize } = this;
5252
const withFirstAndLast = typeof options.withFirstAndLast === 'undefined' ?
5353
Const.With_FIRST_AND_LAST : options.withFirstAndLast;
@@ -62,6 +62,7 @@ class StateProvider extends React.Component {
6262
return {
6363
...options,
6464
bootstrap4,
65+
tableId,
6566
page: currPage,
6667
sizePerPage: currSizePerPage,
6768
pageStartIndex,

packages/react-bootstrap-table2/src/contexts/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ const withContext = Base =>
226226
isRemotePagination={ this.isRemotePagination }
227227
remoteEmitter={ this.remoteEmitter }
228228
onDataSizeChange={ this.props.onDataSizeChange }
229+
tableId={ this.props.id }
229230
>
230231
<this.PaginationContext.Consumer>
231232
{

0 commit comments

Comments
 (0)