File tree 3 files changed +38
-10
lines changed
3 files changed +38
-10
lines changed Original file line number Diff line number Diff line change @@ -1268,6 +1268,7 @@ class BootstrapTable extends Component {
1268
1268
< div className = 'react-bs-table-pagination' >
1269
1269
< PaginationList
1270
1270
ref = { node => this . pagination = node }
1271
+ version = { this . props . version }
1271
1272
withFirstAndLast = { withFirstAndLast }
1272
1273
alwaysShowAllBtns = { options . alwaysShowAllBtns }
1273
1274
currPage = { this . state . currPage }
Original file line number Diff line number Diff line change @@ -178,21 +178,36 @@ class PaginationList extends Component {
178
178
}
179
179
180
180
if ( dropdownProps || ! dropdown ) {
181
+ const isBootstrap4 = Util . isBootstrap4 ( this . props . version ) ;
181
182
const sizePerPageOptions = sizePerPageList . map ( ( _sizePerPage ) => {
182
183
const pageText = _sizePerPage . text || _sizePerPage ;
183
184
const pageNum = _sizePerPage . value || _sizePerPage ;
184
185
if ( sizePerPage === pageNum ) sizePerPageText = pageText ;
185
- return (
186
- < li key = { pageText } role = 'presentation' className = 'dropdown-item' >
187
- < a role = 'menuitem'
188
- tabIndex = '-1' href = '#'
189
- data-page = { pageNum }
186
+ if ( isBootstrap4 ) {
187
+ return (
188
+ < a
189
+ href = '#'
190
+ tabIndex = '-1'
191
+ key = { pageText }
192
+ className = 'dropdown-item'
190
193
onMouseDown = { e => {
191
194
e . preventDefault ( ) ;
192
195
this . changeSizePerPage ( pageNum ) ;
193
196
} } > { pageText } </ a >
194
- </ li >
195
- ) ;
197
+ ) ;
198
+ } else {
199
+ return (
200
+ < li key = { pageText } role = 'presentation' className = 'dropdown-item' >
201
+ < a role = 'menuitem'
202
+ tabIndex = '-1' href = '#'
203
+ data-page = { pageNum }
204
+ onMouseDown = { e => {
205
+ e . preventDefault ( ) ;
206
+ this . changeSizePerPage ( pageNum ) ;
207
+ } } > { pageText } </ a >
208
+ </ li >
209
+ ) ;
210
+ }
196
211
} ) ;
197
212
dropdown = (
198
213
< SizePerPageDropDown
@@ -202,6 +217,7 @@ class PaginationList extends Component {
202
217
options = { sizePerPageOptions }
203
218
onClick = { this . toggleDropDown }
204
219
onBlur = { this . closeDropDown }
220
+ isBootstrap4 = { isBootstrap4 }
205
221
{ ...dropdownProps } />
206
222
) ;
207
223
}
Original file line number Diff line number Diff line change @@ -14,18 +14,31 @@ class SizePerPageDropDown extends Component {
14
14
className,
15
15
variation,
16
16
btnContextual,
17
+ isBootstrap4,
17
18
currSizePerPage
18
19
} = this . props ;
19
20
20
21
const openClass = open ? 'open show' : '' ;
21
22
const dropDownStyle = { visibility : hidden ? 'hidden' : 'visible' } ;
22
23
24
+ const renderOptions = ( ) => {
25
+ const attrs = {
26
+ className : `dropdown-menu ${ openClass } ` ,
27
+ role : 'menu' ,
28
+ 'aria-labelledby' : 'pageDropDown'
29
+ } ;
30
+ const type = isBootstrap4 ? 'div' : 'ul' ;
31
+
32
+ return React . createElement ( type , attrs , options ) ;
33
+ } ;
34
+
23
35
return (
24
36
< span style = { dropDownStyle }
25
37
className = { `${ variation } ${ openClass } ${ className } ${ sizePerPageDefaultClass } ` } >
26
38
< button className = { `btn ${ btnContextual } dropdown-toggle` }
27
39
id = 'pageDropDown' data-toggle = 'dropdown'
28
40
aria-expanded = { open }
41
+ aria-haspopup = { ! open }
29
42
onClick = { onClick }
30
43
onBlur = { onBlur } >
31
44
{ currSizePerPage }
@@ -34,9 +47,7 @@ class SizePerPageDropDown extends Component {
34
47
< span className = 'caret' />
35
48
</ span >
36
49
</ button >
37
- < ul className = 'dropdown-menu' role = 'menu' aria-labelledby = 'pageDropDown' >
38
- { options }
39
- </ ul >
50
+ { renderOptions ( ) }
40
51
</ span >
41
52
) ;
42
53
}
You can’t perform that action at this time.
0 commit comments