diff --git a/packages/vuetify/src/components/VDivider/VDivider.tsx b/packages/vuetify/src/components/VDivider/VDivider.tsx index d2b9fe80be2..60961165d2e 100644 --- a/packages/vuetify/src/components/VDivider/VDivider.tsx +++ b/packages/vuetify/src/components/VDivider/VDivider.tsx @@ -10,7 +10,7 @@ import { makeThemeProps, provideTheme } from '@/composables/theme' import { computed, toRef } from 'vue' import { convertToUnit, genericComponent, propsFactory, useRender } from '@/util' -type DividerKey = 'borderRightWidth' | 'borderTopWidth' | 'maxHeight' | 'maxWidth' +type DividerKey = 'borderRightWidth' | 'borderTopWidth' | 'height' | 'width' type DividerStyles = Partial> export const makeVDividerProps = propsFactory({ @@ -37,7 +37,7 @@ export const VDivider = genericComponent()({ const styles: DividerStyles = {} if (props.length) { - styles[props.vertical ? 'maxHeight' : 'maxWidth'] = convertToUnit(props.length) + styles[props.vertical ? 'height' : 'width'] = convertToUnit(props.length) } if (props.thickness) { diff --git a/packages/vuetify/src/components/VDivider/__tests__/VDivider.spec.cy.tsx b/packages/vuetify/src/components/VDivider/__tests__/VDivider.spec.cy.tsx new file mode 100644 index 00000000000..9a29830a93c --- /dev/null +++ b/packages/vuetify/src/components/VDivider/__tests__/VDivider.spec.cy.tsx @@ -0,0 +1,244 @@ +/// + +import { VDivider } from '..' +import { VList, VListItem } from '../../VList' +import { VCard } from '../../VCard' +import { VToolbar } from '../../VToolbar' +import { VBtn } from '../../VBtn' +import { VCol, VRow, VSpacer } from '../../VGrid' + +// Tests +describe('VDivider', () => { + describe('examples in documentation', () => { + it('takes full height in flexbox container with static height', () => { + cy.mount(() => ( + <> +
+ +
+ + )) + .get("[data-test='divider-v']") + .should('have.length', 1) + .should('have.css', 'height', '200px') + }) + + it('takes defined length when used as centered separator in VToolbar', () => { + cy.mount(() => ( + <> + + + + + + + + + + + + + )) + .get("[data-test='divider-v']") + .should('have.length', 1) + .should('have.css', 'height', '24px') + }) + }) + + describe('adaptive height', () => { + it('takes full height in flexbox container with dynamic height', () => { + cy.mount(() => ( + <> +
+
+ + +
+ {[1, 2, 3, 4, 5, 6, 7, 8].map(idx => ( + + ))} +
+
+
footer
+
+ + )) + .get("[data-test='divider-v']") + .should('have.length', 1) + .should('have.css', 'height', '272px') // 272 = 3 * 80px (card height) + 2 * 16px (ga-4) + }) + + it('takes relative height in flexbox container with dynamic height', () => { + cy.mount(() => ( + <> +
+ + +
Content
+
+ + )) + .get("[data-test='divider-v']") + .should('have.length', 1) + .should('have.css', 'height', '300px') + }) + }) + + describe('separator in list', () => { + it('takes full width in VList', () => { + cy.mount(() => ( + <> +
+ +
+ + )) + .get("[data-test='divider-h']") + .should('have.length', 2) + .should('have.css', 'width', '184px') + }) + }) + + describe('separator in grid', () => { + it('takes only necessary height when grid wraps', () => { + cy.mount(() => ( + <> +
+ + {[0, 1, 2, 3, 4, 5, 6, 7, 8].map(idx => ( + <> + { idx % 4 !== 0 && ( + + )} + + + + + ))} + +
+ + )) + .get("[data-test*='divider-v-']") + .should('have.length', 6) + .should('have.css', 'height', '104px') // 80px + 2 * 12px (v-col) + }) + }) + + describe('vertical inset variant', () => { + it('accepts `inset` prop to get predefined margin', () => { + cy.mount(() => ( + <> +
+ +
+ + )) + .get("[data-test='divider-v']") + .should('have.length', 1) + .should('have.css', 'height', '184px') // 200px - 2 * 8px (inset margin) + }) + + it('accepts custom margin', () => { + cy.mount(() => ( + <> +
+ +
+
+ + +
+ + )) + .get("[data-test='divider-v']") + .should('have.length', 2) + .should('have.css', 'height', '152px') // 200px - 2 * 24px (margin) + }) + }) +})