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>
This commit is contained in:
Alan Chambers
2023-02-02 16:53:38 +00:00
committed by GitHub
parent 400f9b76d5
commit f45fb6848f

View File

@@ -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>