Skip to content

Commit 6f7ce1b

Browse files
committed
fix: add listeners to anchor & popover to improve navigation
1 parent e877318 commit 6f7ce1b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/component/vcf-breadcrumb.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,18 @@ class VcfBreadcrumb extends ElementMixin(ThemableMixin(PolylitMixin(LitElement))
109109
anchor.setAttribute("id", this.id);
110110
const popover = this.querySelector('vaadin-popover[for="' + this.id + '"]');
111111
if (popover) {
112+
anchor.addEventListener("keydown", (event) => {
113+
if (event.key === " " || event.key === "Space") {
114+
event.preventDefault();
115+
// @ts-ignore
116+
popover.opened = !popover.opened;
117+
}
118+
});
119+
popover.addEventListener("opened-changed", (event) => {
120+
if (!((event as CustomEvent).detail.value)) {
121+
anchor.focus(); // Return focus to the ellipsis element
122+
}
123+
});
112124
anchor.appendChild(popover);
113125
}
114126
this.removeAttribute("id");

0 commit comments

Comments
 (0)