Skip to content

Commit

Permalink
fix menu selection via type to select
Browse files Browse the repository at this point in the history
  • Loading branch information
claviska committed Aug 20, 2021
1 parent a3626e1 commit c41714c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/components/menu/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ export default class SlMenu extends LitElement {
clearTimeout(this.typeToSelectTimeout);
this.typeToSelectTimeout = setTimeout(() => (this.typeToSelectString = ''), 750);
this.typeToSelectString += key.toLowerCase();

// The menu may not have focus, so the focus visible logic may not be triggered. Because we know they're using the
// keyboard, we can force the sl-focus-visible class on each item so the selection shows as expected.
this.getAllItems().map(item => item.classList.add('sl-focus-visible'));

for (const item of items) {
const slot = item.shadowRoot!.querySelector('slot:not([name])') as HTMLSlotElement;
const label = getTextContent(slot).toLowerCase().trim();
Expand Down

0 comments on commit c41714c

Please sign in to comment.