Skip to content

Commit

Permalink
refactor(menu): removed setReturnFocus
Browse files Browse the repository at this point in the history
  • Loading branch information
roomman committed Oct 7, 2021
1 parent c2620f8 commit 9f44fa4
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 48 deletions.
1 change: 0 additions & 1 deletion addon/components/menu/items.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
clickOutsideDeactivates=this.clickOutsideFocusTrapDeactivates
fallbackFocus=this.menuItemsElementSelector
initialFocus=this.menuItemsElementSelector
setReturnFocus=@setReturnFocus
onDeactivate=@closeMenu
)
}}
Expand Down
47 changes: 0 additions & 47 deletions tests/integration/components/menu-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -934,53 +934,6 @@ module('Integration | Component | <Menu>', (hooks) => {
// Verify the button is focused again
await assertActiveElement(getMenuButton());
});

test('it should be possible to close the menu with Escape, and return focus to another element', async function (assert) {
await render(hbs`
<button type="button" data-test-alternate-button>Other Target</button>
<Menu as |menu|>
<menu.Button data-test-menu-button>Trigger</menu.Button>
<menu.Items @setReturnFocus="[data-test-alternate-button]" data-test-menu-items as |items|>
<items.Item as |item|>
<item.Element>
Item A
</item.Element>
</items.Item>
<items.Item as |item|>
<item.Element>
Item B
</item.Element>
</items.Item>
<items.Item as |item|>
<item.Element>
Item C
</item.Element>
</items.Item>
</menu.Items>
</Menu>
`);

// Verify it is closed
assertClosedMenuButton('[data-test-menu-button]');

// Focus the button
getMenuButton()?.focus();

// Open menu
await triggerKeyEvent('[data-test-menu-button]', 'keydown', Keys.Space);

// Verify it is open
assertOpenMenuButton('[data-test-menu-button]');

// Close menu
await triggerKeyEvent('[data-test-menu-items]', 'keydown', Keys.Escape);

// Verify it is closed
assertClosedMenuButton('[data-test-menu-button]');

// Verify the alternate element has focus
assert.dom('[data-test-alternate-button]').isFocused();
});
});

module('`Tab` key', () => {
Expand Down

0 comments on commit 9f44fa4

Please sign in to comment.