Skip to content

Commit 56a6099

Browse files
committed
Allow customTag in NavigatorCardItem
1 parent a228635 commit 56a6099

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/components/Navigator/NavigatorCardItem.vue

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,10 @@ export default {
184184
type: Object,
185185
default: () => ({}),
186186
},
187+
customTag: {
188+
type: String,
189+
require: false,
190+
},
187191
},
188192
idState() {
189193
return {
@@ -204,7 +208,11 @@ export default {
204208
),
205209
isBeta: ({ item: { beta } }) => !!beta,
206210
isDeprecated: ({ item: { deprecated } }) => !!deprecated,
207-
refComponent: ({ isGroupMarker }) => (isGroupMarker ? 'h3' : Reference),
211+
refComponent: ({ isGroupMarker, customTag }) => {
212+
if (customTag) return customTag;
213+
if (isGroupMarker) return 'h3';
214+
return Reference;
215+
},
208216
},
209217
methods: {
210218
toggleTree() {

tests/unit/components/Navigator/NavigatorCardItem.spec.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,16 @@ describe('NavigatorCardItem', () => {
8686
expect(cardItem.attributes('data-nesting-index')).toBe(String(defaultProps.item.depth));
8787
});
8888

89+
it('renders a custom tag for the leaf-link if customTag is defined', () => {
90+
const wrapper = createWrapper({
91+
propsData: {
92+
customTag: 'button',
93+
},
94+
});
95+
const leafLink = wrapper.find('.leaf-link');
96+
expect(leafLink.is('button')).toBe(true);
97+
});
98+
8999
it('renders the NavigationCardItem with an icon override', () => {
90100
const navigatorReferences = {
91101
iconRef: {

0 commit comments

Comments
 (0)