FIX: Focus first button in topic admin menu (#10562)
When using Shift+A to toggle the admin menu for a topic the first button was not focused, so the menu could not be navigated with tab.
This commit is contained in:
parent
5ec5fbd7ba
commit
594d919d22
|
@ -108,6 +108,16 @@ createWidget("topic-admin-menu-button", {
|
|||
this.state.position = position;
|
||||
},
|
||||
|
||||
didRenderWidget() {
|
||||
let menuButtons = document.querySelectorAll(
|
||||
".topic-admin-popup-menu button"
|
||||
);
|
||||
|
||||
if (menuButtons && menuButtons[0]) {
|
||||
menuButtons[0].focus();
|
||||
}
|
||||
},
|
||||
|
||||
topicToggleActions() {
|
||||
this.state.expanded ? this.hideAdminMenu() : this.showAdminMenu();
|
||||
}
|
||||
|
|
|
@ -34,3 +34,16 @@ QUnit.test(
|
|||
);
|
||||
}
|
||||
);
|
||||
|
||||
QUnit.test("Toggle the menu as admin focuses the first item", async assert => {
|
||||
updateCurrentUser({ admin: true });
|
||||
|
||||
await visit("/t/internationalization-localization/280");
|
||||
assert.ok(exists("#topic"), "The topic was rendered");
|
||||
await click(".toggle-admin-menu");
|
||||
|
||||
assert.equal(
|
||||
document.activeElement,
|
||||
document.querySelector(".topic-admin-multi-select > button")
|
||||
);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue