mirror of
https://github.com/element-hq/element-web
synced 2024-11-28 04:21:57 +03:00
Simplify aria menu item roles/selectors
This commit is contained in:
parent
a6c780674a
commit
b373b98d48
1 changed files with 2 additions and 5 deletions
|
@ -44,9 +44,6 @@ function getOrCreateContainer(): HTMLDivElement {
|
||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ARIA_MENU_ITEM_ROLES = new Set(["menuitem", "menuitemcheckbox", "menuitemradio"]);
|
|
||||||
const ARIA_MENU_ITEM_SELECTOR = '[role^="menuitem"], [role^="menuitemcheckbox"], [role^="menuitemradio"]';
|
|
||||||
|
|
||||||
export interface IPosition {
|
export interface IPosition {
|
||||||
top?: number;
|
top?: number;
|
||||||
bottom?: number;
|
bottom?: number;
|
||||||
|
@ -117,7 +114,7 @@ export class ContextMenu extends React.PureComponent<IProps, IState> {
|
||||||
// We don't need to clean up when unmounting, so ignore
|
// We don't need to clean up when unmounting, so ignore
|
||||||
if (!element) return;
|
if (!element) return;
|
||||||
|
|
||||||
const first = element.querySelector<HTMLElement>(ARIA_MENU_ITEM_SELECTOR)
|
const first = element.querySelector<HTMLElement>('[role^="menuitem"]')
|
||||||
|| element.querySelector<HTMLElement>('[tab-index]');
|
|| element.querySelector<HTMLElement>('[tab-index]');
|
||||||
|
|
||||||
if (first) {
|
if (first) {
|
||||||
|
@ -196,7 +193,7 @@ export class ContextMenu extends React.PureComponent<IProps, IState> {
|
||||||
descending = true;
|
descending = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (element && !ARIA_MENU_ITEM_ROLES.has(element.getAttribute("role")));
|
} while (element && !element.getAttribute("role")?.startsWith("menuitem"));
|
||||||
|
|
||||||
if (element) {
|
if (element) {
|
||||||
(element as HTMLElement).focus();
|
(element as HTMLElement).focus();
|
||||||
|
|
Loading…
Reference in a new issue