Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 5 additions & 1 deletion src/components/Button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as Expensicons from '@components/Icon/Expensicons';
import PressableWithFeedback from '@components/Pressable/PressableWithFeedback';
import Text from '@components/Text';
import withNavigationFallback from '@components/withNavigationFallback';
import useActiveElement from '@hooks/useActiveElement';
import useKeyboardShortcut from '@hooks/useKeyboardShortcut';
import HapticFeedback from '@libs/HapticFeedback';
import useTheme from '@styles/themes/useTheme';
Expand Down Expand Up @@ -158,6 +159,9 @@ function Button(
const theme = useTheme();
const styles = useThemeStyles();
const isFocused = useIsFocused();
const activeElement = useActiveElement();
const accessibilityRoles: string[] = Object.values(CONST.ACCESSIBILITY_ROLE);
const shouldDisableEnterShortcut = accessibilityRoles.includes(activeElement?.role ?? '') && activeElement?.role !== CONST.ACCESSIBILITY_ROLE.TEXT;

const keyboardShortcutCallback = useCallback(
(event?: GestureResponderEvent | KeyboardEvent) => {
Expand All @@ -170,7 +174,7 @@ function Button(
);

useKeyboardShortcut(CONST.KEYBOARD_SHORTCUTS.ENTER, keyboardShortcutCallback, {
isActive: pressOnEnter,
isActive: pressOnEnter && !shouldDisableEnterShortcut,
shouldBubble: allowBubble,
priority: enterKeyEventListenerPriority,
shouldPreventDefault: false,
Expand Down
2 changes: 1 addition & 1 deletion src/components/Pressable/GenericPressable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function WebGenericPressable({focusable = true, ...props}: PressableProps, ref:
// change native accessibility props to web accessibility props
focusable={focusable}
tabIndex={props.tabIndex ?? (!accessible || !focusable) ? -1 : 0}
role={props.accessibilityRole as Role}
role={(props.accessibilityRole ?? props.role) as Role}
id={props.nativeID}
aria-label={props.accessibilityLabel}
aria-labelledby={props.accessibilityLabelledBy}
Expand Down