File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -193,10 +193,14 @@ export const VPagination = genericComponent<VPaginationSlots>()({
193193 const range = computed ( ( ) => {
194194 if ( length . value <= 0 || isNaN ( length . value ) || length . value > Number . MAX_SAFE_INTEGER ) return [ ]
195195
196+
196197 if ( totalVisible . value <= 0 ) return [ ]
197198 else if ( totalVisible . value === 1 ) return [ page . value ]
198199
199- if ( length . value <= totalVisible . value ) {
200+ if (
201+ length . value <= totalVisible . value
202+ || props . totalVisible == null && length . value < 3
203+ ) {
200204 return createRange ( length . value , start . value )
201205 }
202206
Original file line number Diff line number Diff line change @@ -23,6 +23,28 @@ describe('VPagination', () => {
2323 expect ( screen . getAllByCSS ( '.v-pagination__item' ) ) . toHaveLength ( 3 )
2424 } )
2525
26+ it ( 'should render all pages when length is less than 3 in a flexbox container' , async ( ) => {
27+ render ( ( ) => (
28+ < div class = "d-flex" >
29+ < VPagination length = "2" />
30+ </ div >
31+ ) )
32+
33+ expect ( screen . getAllByCSS ( '.v-pagination__item' ) ) . toHaveLength ( 2 )
34+ expect ( screen . getAllByCSS ( '.v-pagination__item .v-btn' ) . at ( 0 ) ) . toHaveTextContent ( '1' )
35+ expect ( screen . getAllByCSS ( '.v-pagination__item .v-btn' ) . at ( 1 ) ) . toHaveTextContent ( '2' )
36+ } )
37+
38+ it ( 'should still honor an explicit total-visible when length is less than 3' , ( ) => {
39+ render ( ( ) => (
40+ < div class = "d-flex" >
41+ < VPagination length = "2" totalVisible = "1" />
42+ </ div >
43+ ) )
44+
45+ expect ( screen . getAllByCSS ( '.v-pagination__item' ) ) . toHaveLength ( 1 )
46+ } )
47+
2648 it ( 'should render without first and last page buttons' , ( ) => {
2749 render ( ( ) => (
2850 < VPagination showFirstLastPage = { false } length = "3" />
You can’t perform that action at this time.
0 commit comments