You've already forked matrix-react-sdk
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:
@@ -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) {
|
||||||
|
@@ -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
|
||||||
|
Reference in New Issue
Block a user