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

Commit d3bd43d

Browse files
committed
Fix TAC opening with keyboard
1 parent f2101c6 commit d3bd43d

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/components/views/elements/AccessibleButton.tsx

+9-1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ type Props<T extends keyof JSX.IntrinsicElements> = DynamicHtmlElementProps<T> &
8686
* Event handler for button activation. Should be implemented exactly like a normal `onClick` handler.
8787
*/
8888
onClick: ((e: ButtonEvent) => void | Promise<void>) | null;
89+
/**
90+
* Disable keyboard overrides for this button. Defaults to false.
91+
*/
92+
disableKeyboardOverrides?: boolean;
8993
};
9094

9195
/**
@@ -116,6 +120,7 @@ const AccessibleButton = forwardRef(function <T extends keyof JSX.IntrinsicEleme
116120
onKeyDown,
117121
onKeyUp,
118122
triggerOnMouseDown,
123+
disableKeyboardOverrides = false,
119124
...restProps
120125
}: Props<T>,
121126
ref: Ref<HTMLElement>,
@@ -138,8 +143,9 @@ const AccessibleButton = forwardRef(function <T extends keyof JSX.IntrinsicEleme
138143
// Browsers handle space and enter key presses differently and we are only adjusting to the
139144
// inconsistencies here
140145
newProps.onKeyDown = (e) => {
141-
const action = getKeyBindingsManager().getAccessibilityAction(e);
146+
if (disableKeyboardOverrides) return onKeyDown?.(e);
142147

148+
const action = getKeyBindingsManager().getAccessibilityAction(e);
143149
switch (action) {
144150
case KeyBindingAction.Enter:
145151
e.stopPropagation();
@@ -154,6 +160,8 @@ const AccessibleButton = forwardRef(function <T extends keyof JSX.IntrinsicEleme
154160
}
155161
};
156162
newProps.onKeyUp = (e) => {
163+
if (disableKeyboardOverrides) return onKeyUp?.(e);
164+
157165
const action = getKeyBindingsManager().getAccessibilityAction(e);
158166

159167
switch (action) {

src/components/views/spaces/threads-activity-centre/ThreadsActivityCentreButton.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export const ThreadsActivityCentreButton = forwardRef<HTMLDivElement, ThreadsAct
5151
ref={ref}
5252
forceHide={displayLabel}
5353
aria-expanded={displayLabel}
54+
disableKeyboardOverrides={true}
5455
{...props}
5556
>
5657
<IndicatorIcon

0 commit comments

Comments
 (0)