1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-08-09 08:42:50 +03:00

Fix TAC opening with keyboard

This commit is contained in:
Florian Duros
2024-02-26 15:50:38 +01:00
parent f2101c69ec
commit 5a1e5d0c45
2 changed files with 11 additions and 1 deletions

View File

@@ -86,6 +86,10 @@ type Props<T extends keyof JSX.IntrinsicElements> = DynamicHtmlElementProps<T> &
* Event handler for button activation. Should be implemented exactly like a normal `onClick` handler.
*/
onClick: ((e: ButtonEvent) => void | Promise<void>) | null;
/**
* Disable keyboard overrides for this button. Defaults to false.
*/
disableKeyboardOverrides?: boolean;
};
/**
@@ -116,6 +120,7 @@ const AccessibleButton = forwardRef(function <T extends keyof JSX.IntrinsicEleme
onKeyDown,
onKeyUp,
triggerOnMouseDown,
disableKeyboardOverrides = false,
...restProps
}: Props<T>,
ref: Ref<HTMLElement>,
@@ -138,8 +143,9 @@ const AccessibleButton = forwardRef(function <T extends keyof JSX.IntrinsicEleme
// Browsers handle space and enter key presses differently and we are only adjusting to the
// inconsistencies here
newProps.onKeyDown = (e) => {
const action = getKeyBindingsManager().getAccessibilityAction(e);
if (disableKeyboardOverrides) return onKeyDown?.(e);
const action = getKeyBindingsManager().getAccessibilityAction(e);
switch (action) {
case KeyBindingAction.Enter:
e.stopPropagation();
@@ -154,6 +160,8 @@ const AccessibleButton = forwardRef(function <T extends keyof JSX.IntrinsicEleme
}
};
newProps.onKeyUp = (e) => {
if (disableKeyboardOverrides) return onKeyUp?.(e);
const action = getKeyBindingsManager().getAccessibilityAction(e);
switch (action) {

View File

@@ -51,6 +51,8 @@ export const ThreadsActivityCentreButton = forwardRef<HTMLDivElement, ThreadsAct
ref={ref}
forceHide={displayLabel}
aria-expanded={displayLabel}
// The compound component Menu is already handling the keyboard events
disableKeyboardOverrides={true}
{...props}
>
<IndicatorIcon