From 756f791a1a8dd3a4a88c212b4e4f775584decb55 Mon Sep 17 00:00:00 2001 From: Benjamin Canac Date: Fri, 15 Nov 2024 09:52:42 +0100 Subject: [PATCH] fix(Breadcrumb): render as `nav` Resolves #2649 --- src/runtime/components/Breadcrumb.vue | 3 +- test/components/Breadcrumb.spec.ts | 1 + .../__snapshots__/Breadcrumb-vue.spec.ts.snap | 57 ++++++++++++------- .../__snapshots__/Breadcrumb.spec.ts.snap | 57 ++++++++++++------- 4 files changed, 73 insertions(+), 45 deletions(-) diff --git a/src/runtime/components/Breadcrumb.vue b/src/runtime/components/Breadcrumb.vue index 5bb26970..6cead957 100644 --- a/src/runtime/components/Breadcrumb.vue +++ b/src/runtime/components/Breadcrumb.vue @@ -21,7 +21,7 @@ export interface BreadcrumbItem extends Omit { export interface BreadcrumbProps { /** * The element or component this component should render as. - * @defaultValue 'div' + * @defaultValue 'nav' */ as?: any items?: T[] @@ -88,6 +88,7 @@ import ULinkBase from './LinkBase.vue' import ULink from './Link.vue' const props = withDefaults(defineProps>(), { + as: 'nav', labelKey: 'label' }) const slots = defineSlots>() diff --git a/test/components/Breadcrumb.spec.ts b/test/components/Breadcrumb.spec.ts index e47ebe89..73d67702 100644 --- a/test/components/Breadcrumb.spec.ts +++ b/test/components/Breadcrumb.spec.ts @@ -25,6 +25,7 @@ describe('Breadcrumb', () => { it.each([ // Props ['with items', { props }], + ['with as', { props: { ...props, as: 'div' } }], ['with labelKey', { props: { ...props, labelKey: 'icon' } }], ['with separatorIcon', { props: { ...props, separatorIcon: 'i-lucide-minus' } }], ['with class', { props: { ...props, class: 'w-48' } }], diff --git a/test/components/__snapshots__/Breadcrumb-vue.spec.ts.snap b/test/components/__snapshots__/Breadcrumb-vue.spec.ts.snap index 3e92b8ef..1f2f8dd7 100644 --- a/test/components/__snapshots__/Breadcrumb-vue.spec.ts.snap +++ b/test/components/__snapshots__/Breadcrumb-vue.spec.ts.snap @@ -1,7 +1,7 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Breadcrumb > renders with class correctly 1`] = ` -"
+exports[`Breadcrumb > renders with as correctly 1`] = ` +"
  1. Home
  2. @@ -13,8 +13,21 @@ exports[`Breadcrumb > renders with class correctly 1`] = `
" `; +exports[`Breadcrumb > renders with class correctly 1`] = ` +"" +`; + exports[`Breadcrumb > renders with custom slot correctly 1`] = ` -"
+"
" +" `; exports[`Breadcrumb > renders with item slot correctly 1`] = ` -"
+"
" +" `; exports[`Breadcrumb > renders with item-label slot correctly 1`] = ` -"
+"
" +" `; exports[`Breadcrumb > renders with item-leading slot correctly 1`] = ` -"
+"
" +" `; exports[`Breadcrumb > renders with item-trailing slot correctly 1`] = ` -"
+"
" +" `; exports[`Breadcrumb > renders with items correctly 1`] = ` -"
+"
" +" `; exports[`Breadcrumb > renders with labelKey correctly 1`] = ` -"" +" `; exports[`Breadcrumb > renders with separator slot correctly 1`] = ` -"
+"
" +" `; exports[`Breadcrumb > renders with separatorIcon correctly 1`] = ` -"
+"
" +" `; exports[`Breadcrumb > renders with ui correctly 1`] = ` -"
+"
" +" `; diff --git a/test/components/__snapshots__/Breadcrumb.spec.ts.snap b/test/components/__snapshots__/Breadcrumb.spec.ts.snap index db204661..af11b25b 100644 --- a/test/components/__snapshots__/Breadcrumb.spec.ts.snap +++ b/test/components/__snapshots__/Breadcrumb.spec.ts.snap @@ -1,7 +1,7 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Breadcrumb > renders with class correctly 1`] = ` -"
+exports[`Breadcrumb > renders with as correctly 1`] = ` +"
  1. Home
  2. @@ -13,8 +13,21 @@ exports[`Breadcrumb > renders with class correctly 1`] = `
" `; +exports[`Breadcrumb > renders with class correctly 1`] = ` +"" +`; + exports[`Breadcrumb > renders with custom slot correctly 1`] = ` -"
+"
" +" `; exports[`Breadcrumb > renders with item slot correctly 1`] = ` -"
+"
" +" `; exports[`Breadcrumb > renders with item-label slot correctly 1`] = ` -"
+"
" +" `; exports[`Breadcrumb > renders with item-leading slot correctly 1`] = ` -"
+"
" +" `; exports[`Breadcrumb > renders with item-trailing slot correctly 1`] = ` -"
+"
" +" `; exports[`Breadcrumb > renders with items correctly 1`] = ` -"
+"
" +" `; exports[`Breadcrumb > renders with labelKey correctly 1`] = ` -"" +" `; exports[`Breadcrumb > renders with separator slot correctly 1`] = ` -"
+"
" +" `; exports[`Breadcrumb > renders with separatorIcon correctly 1`] = ` -"
+"
" +" `; exports[`Breadcrumb > renders with ui correctly 1`] = ` -"
+"
" +" `;