Adjust sl-dropdown up/down keypress menuItems array to match menu (#1170)

* dropdown filtered menu items

* updated filter, added test

- updated filter to match menu getAllItems private method
- added test

---------

Co-authored-by: Cory LaViska <cory@abeautifulsite.net>
pull/1186/head
Alan Chambers 2023-02-02 16:53:38 +00:00 zatwierdzone przez GitHub
rodzic 400f9b76d5
commit f45fb6848f
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
1 zmienionych plików z 21 dodań i 0 usunięć

Wyświetl plik

@ -179,6 +179,27 @@ describe('<sl-dropdown>', () => {
expect(el.open).to.be.true;
});
it('should navigate to first focusable item on arrow navigation', async () => {
const el = await fixture<SlDropdown>(html`
<sl-dropdown>
<sl-button slot="trigger" caret>Toggle</sl-button>
<sl-menu>
<sl-menu-label>Top Label</sl-menu-label>
<sl-menu-item>Item 1</sl-menu-item>
</sl-menu>
</sl-dropdown>
`);
const trigger = el.querySelector('sl-button')!;
const item = el.querySelector('sl-menu-item')!;
trigger.focus();
await sendKeys({ press: 'ArrowDown' });
await el.updateComplete;
const itemFocused = document.activeElement === item;
expect(itemFocused).to.be.true;
});
it('should close on escape key', async () => {
const el = await fixture<SlDropdown>(html`
<sl-dropdown open>