kopia lustrzana https://github.com/shoelace-style/shoelace
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
rodzic
400f9b76d5
commit
f45fb6848f
|
@ -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>
|
||||
|
|
Ładowanie…
Reference in New Issue