Skip to content

Commit 658b6a6

Browse files
JesmoDeviOvergaard
andauthored
fix: Dont show a link when no href is supplied (#797)
* dont show a tag when no href is supplied * cleanup * chore: prettier * chore: update tests to reflect the new possibilities in breadcrumb-item --------- Co-authored-by: Jacob Overgaard <[email protected]>
1 parent 1fde167 commit 658b6a6

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

packages/uui-breadcrumbs/lib/uui-breadcrumb-item.element.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ export class UUIBreadcrumbItemElement extends LitElement {
2020
/**
2121
* Specifies the link href.
2222
* @type {String}
23-
* @default '#'
23+
* @default undefined
2424
*/
2525
@property()
26-
href = '#';
26+
href?: string;
2727

2828
/**
2929
* Specifies if the element is the last item in the uui-breadcrumbs. Last item will not render as a link
@@ -35,8 +35,11 @@ export class UUIBreadcrumbItemElement extends LitElement {
3535
lastItem = false;
3636

3737
renderLinkAndSeparator() {
38-
return html`<a id="link" href=${this.href}><slot></slot></a
39-
><span part="separator"></span>`;
38+
const item = this.href
39+
? html`<a id="link" href=${this.href}><slot></slot></a>`
40+
: html`<span id="link"><slot></slot></span>`;
41+
42+
return html`${item}<span part="separator"></span>`;
4043
}
4144

4245
renderCurrent() {
@@ -84,10 +87,6 @@ export class UUIBreadcrumbItemElement extends LitElement {
8487
overflow: hidden;
8588
text-overflow: ellipsis;
8689
}
87-
88-
#link {
89-
cursor: pointer;
90-
}
9190
`,
9291
];
9392
}

packages/uui-breadcrumbs/lib/uui-breadcrumb-item.test.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ describe('UuiBreadcrumbItem', () => {
1313

1414
it('is a link if not last item', async () => {
1515
const element = await fixture<UUIBreadcrumbItemElement>(html`
16-
<uui-breadcrumb-item>One</uui-breadcrumb-item>
16+
<uui-breadcrumb-item href="/test">One</uui-breadcrumb-item>
1717
`);
1818

1919
const link = element.shadowRoot!.querySelector('a')!;
@@ -27,4 +27,12 @@ describe('UuiBreadcrumbItem', () => {
2727
const span = element.shadowRoot!.querySelector('span')!;
2828
expect(span).to.exist;
2929
});
30+
31+
it('is a span if no href', async () => {
32+
const element = await fixture<UUIBreadcrumbItemElement>(html`
33+
<uui-breadcrumb-item>One</uui-breadcrumb-item>
34+
`);
35+
const span = element.shadowRoot!.querySelector('span')!;
36+
expect(span).to.exist;
37+
});
3038
});

packages/uui-tag/lib/uui-tag.element.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ export class UUITagElement extends LitElement {
4848
font-size: var(--uui-tag-font-size, var(--uui-type-small-size));
4949
font-weight: 700;
5050
line-height: 1;
51-
padding: var(--uui-tag-padding, var(--uui-size-space-1) calc(var(--uui-size-space-1) + 0.5em));
51+
padding: var(
52+
--uui-tag-padding,
53+
var(--uui-size-space-1) calc(var(--uui-size-space-1) + 0.5em)
54+
);
5255
border-radius: 100px;
5356
user-select: none;
5457
border-radius: var(--uui-tag-border-radius, var(--uui-size-4));

0 commit comments

Comments
 (0)