Skip to content

Commit c00d94b

Browse files
committed
fix(breadcrumb): add onMount to strip host role for nested navigation landmarks
1 parent 46a9353 commit c00d94b

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

packages/components/src/components/breadcrumb/breadcrumb.lite.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {
2+
onMount,
23
useDefaultProps,
34
useMetadata,
45
useRef,
@@ -27,6 +28,18 @@ export default function DBBreadcrumb(props: DBBreadcrumbProps) {
2728
}
2829
});
2930

31+
// Prevent nested/duplicate navigation landmarks in Stencil by stripping host role
32+
onMount(() => {
33+
try {
34+
const parent = (_ref as any)?.get()?.closest?.('db-breadcrumb');
35+
if (parent && parent.hasAttribute('role')) {
36+
parent.removeAttribute('role');
37+
}
38+
} catch {
39+
/* no-op */
40+
}
41+
});
42+
3043
return (
3144
<nav
3245
ref={_ref}

packages/components/src/components/breadcrumb/breadcrumb.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { DBBreadcrumb } from './index';
1919
import { DEFAULT_VIEWPORT } from '../../shared/constants.ts';
2020

2121
const defaultBreadcrumb: any = (
22-
<DBBreadcrumb>
22+
<DBBreadcrumb ariaLabel="Breadcrumb">
2323
<li>
2424
<a href="#">Home</a>
2525
</li>

0 commit comments

Comments
 (0)