Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Fix TAC opening with keyboard #12285

Merged
merged 10 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/components/views/elements/AccessibleButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

/**
Expand Down Expand Up @@ -116,6 +120,7 @@ const AccessibleButton = forwardRef(function <T extends keyof JSX.IntrinsicEleme
onKeyDown,
onKeyUp,
triggerOnMouseDown,
disableKeyboardOverrides = false,
...restProps
}: Props<T>,
ref: Ref<HTMLElement>,
Expand All @@ -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();
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down