Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prevent initial focus when container has button listen enter event #49023

Merged
merged 2 commits into from
Sep 18, 2024
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
3 changes: 3 additions & 0 deletions src/components/Button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,9 @@ function Button(
/>
)}
<PressableWithFeedback
dataSet={{
listener: pressOnEnter ? CONST.KEYBOARD_SHORTCUTS.ENTER.shortcutKey : undefined,
}}
ref={ref}
onPress={(event) => {
if (event?.type === 'click') {
Expand Down
7 changes: 5 additions & 2 deletions src/components/FocusTrap/FocusTrapForScreen/index.web.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,11 @@ function FocusTrapForScreen({children, focusTrapSettings}: FocusTrapProps) {
return false;
}

const isFocusedElementInsideContainer = focusTrapContainers?.some((container) => container.contains(document.activeElement));
if (isFocusedElementInsideContainer) {
const isFocusedElementInsideContainer = !!focusTrapContainers?.some((container) => container.contains(document.activeElement));
const hasButtonWithEnterListener = !!focusTrapContainers?.some(
(container) => !!container.querySelector(`button[data-listener="${CONST.KEYBOARD_SHORTCUTS.ENTER.shortcutKey}"]`),
);
if (isFocusedElementInsideContainer || hasButtonWithEnterListener) {
return false;
}
return undefined;
Expand Down
Loading