1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-08-10 19:43:07 +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. * Event handler for button activation. Should be implemented exactly like a normal `onClick` handler.
*/ */
onClick: ((e: ButtonEvent) => void | Promise<void>) | null; 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, onKeyDown,
onKeyUp, onKeyUp,
triggerOnMouseDown, triggerOnMouseDown,
disableKeyboardOverrides = false,
...restProps ...restProps
}: Props<T>, }: Props<T>,
ref: Ref<HTMLElement>, 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 // Browsers handle space and enter key presses differently and we are only adjusting to the
// inconsistencies here // inconsistencies here
newProps.onKeyDown = (e) => { newProps.onKeyDown = (e) => {
const action = getKeyBindingsManager().getAccessibilityAction(e); if (disableKeyboardOverrides) return onKeyDown?.(e);
const action = getKeyBindingsManager().getAccessibilityAction(e);
switch (action) { switch (action) {
case KeyBindingAction.Enter: case KeyBindingAction.Enter:
e.stopPropagation(); e.stopPropagation();
@@ -154,6 +160,8 @@ const AccessibleButton = forwardRef(function <T extends keyof JSX.IntrinsicEleme
} }
}; };
newProps.onKeyUp = (e) => { newProps.onKeyUp = (e) => {
if (disableKeyboardOverrides) return onKeyUp?.(e);
const action = getKeyBindingsManager().getAccessibilityAction(e); const action = getKeyBindingsManager().getAccessibilityAction(e);
switch (action) { switch (action) {

View File

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