File tree Expand file tree Collapse file tree 2 files changed +36
-4
lines changed Expand file tree Collapse file tree 2 files changed +36
-4
lines changed Original file line number Diff line number Diff line change @@ -61,11 +61,14 @@ export default mixins(Colorable, Themeable).extend({
61
61
62
62
items ( ) : ( string | number ) [ ] {
63
63
const totalVisible = parseInt ( this . totalVisible , 10 )
64
- const maxLength = totalVisible > this . maxButtons
65
- ? this . maxButtons
66
- : totalVisible || this . maxButtons
67
64
68
- if ( this . length <= maxLength || maxLength < 1 ) {
65
+ const maxLength = Math . min (
66
+ Math . max ( 0 , totalVisible ) || this . length ,
67
+ Math . max ( 0 , this . maxButtons ) || this . length ,
68
+ this . length
69
+ )
70
+
71
+ if ( this . length <= maxLength ) {
69
72
return this . range ( 1 , this . length )
70
73
}
71
74
Original file line number Diff line number Diff line change @@ -244,6 +244,35 @@ describe('VPagination.ts', () => {
244
244
expect ( wrapper . vm . items ) . toHaveLength ( 10 )
245
245
} )
246
246
247
+ it ( 'should never show more than the number of total visible buttons' , ( ) => {
248
+ const wrapper = mountFunction ( {
249
+ data : ( ) => ( {
250
+ maxButtons : 0 ,
251
+ } ) ,
252
+
253
+ propsData : {
254
+ length : 5 ,
255
+ totalVisible : undefined ,
256
+ } ,
257
+ } )
258
+
259
+ expect ( wrapper . vm . items ) . toHaveLength ( 5 )
260
+
261
+ wrapper . setProps ( { length : 40 } )
262
+
263
+ wrapper . setData ( { maxButtons : 0 } )
264
+ wrapper . setProps ( { totalVisible : 10 } )
265
+ expect ( wrapper . vm . items ) . toHaveLength ( 10 )
266
+
267
+ wrapper . setData ( { maxButtons : 11 } )
268
+ wrapper . setProps ( { totalVisible : undefined } )
269
+ expect ( wrapper . vm . items ) . toHaveLength ( 11 )
270
+
271
+ wrapper . setData ( { maxButtons : 12 } )
272
+ wrapper . setProps ( { totalVisible : 13 } )
273
+ expect ( wrapper . vm . items ) . toHaveLength ( 12 )
274
+ } )
275
+
247
276
it ( 'should return length when maxButtons is less than 1' , ( ) => {
248
277
const wrapper = mountFunction ( {
249
278
data : ( ) => ( { maxButtons : - 3 } ) ,
You can’t perform that action at this time.
0 commit comments