From 75b9710f187fd7e78473674a23fc2af636fe5e46 Mon Sep 17 00:00:00 2001 From: Tsaqif Date: Mon, 16 Sep 2024 10:16:00 +0700 Subject: [PATCH] Disable initialFocus and setReturnFocus in focusTrap for screen Signed-off-by: Tsaqif --- .../FocusTrapForScreen/index.web.tsx | 23 ++++--------------- 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/src/components/FocusTrap/FocusTrapForScreen/index.web.tsx b/src/components/FocusTrap/FocusTrapForScreen/index.web.tsx index d9177954044..14f14aee8c7 100644 --- a/src/components/FocusTrap/FocusTrapForScreen/index.web.tsx +++ b/src/components/FocusTrap/FocusTrapForScreen/index.web.tsx @@ -6,7 +6,6 @@ import sharedTrapStack from '@components/FocusTrap/sharedTrapStack'; import TOP_TAB_SCREENS from '@components/FocusTrap/TOP_TAB_SCREENS'; import WIDE_LAYOUT_INACTIVE_SCREENS from '@components/FocusTrap/WIDE_LAYOUT_INACTIVE_SCREENS'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; -import canFocusInputOnScreenFocus from '@libs/canFocusInputOnScreenFocus'; import CONST from '@src/CONST'; import type FocusTrapProps from './FocusTrapProps'; @@ -42,27 +41,15 @@ function FocusTrapForScreen({children, focusTrapSettings}: FocusTrapProps) { paused={!isFocused} containerElements={focusTrapSettings?.containerElements?.length ? focusTrapSettings.containerElements : undefined} focusTrapOptions={{ + onActivate: () => { + (document?.activeElement as HTMLElement)?.blur(); + }, trapStack: sharedTrapStack, allowOutsideClick: true, fallbackFocus: document.body, delayInitialFocus: CONST.ANIMATED_TRANSITION, - initialFocus: (focusTrapContainers) => { - if (!canFocusInputOnScreenFocus()) { - return false; - } - - const isFocusedElementInsideContainer = focusTrapContainers?.some((container) => container.contains(document.activeElement)); - if (isFocusedElementInsideContainer) { - return false; - } - return undefined; - }, - setReturnFocus: (element) => { - if (document.activeElement && document.activeElement !== document.body) { - return false; - } - return element; - }, + initialFocus: false, + setReturnFocus: false, ...(focusTrapSettings?.focusTrapOptions ?? {}), }} >