-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Add focus trap #39520
Add focus trap #39520
Conversation
@@ -113,6 +113,7 @@ | |||
"expo-av": "~13.10.4", | |||
"expo-image": "1.11.0", | |||
"expo-image-manipulator": "11.8.0", | |||
"focus-trap-react": "^10.2.3", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Request was resolved successfully
@@ -0,0 +1,5 @@ | |||
import SCREENS from '@src/SCREENS'; | |||
|
|||
const BOTTOM_TAB_SCREENS: string[] = [SCREENS.HOME, SCREENS.SETTINGS.ROOT]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of string[]
, use BottomTabName[]
DetailsFixed Issues$ #36476 Tests
Offline testsN/A QA StepsSame as in Tests
PR Author Checklist
Screenshots/VideosAndroid: NativeN/A Android: mWeb ChromeN/A iOS: NativeN/A iOS: mWeb SafariN/A MacOS: Chrome / Safariweb-rhp.movweb-context-menu.movMacOS: Desktopdesktop-rhp.movdesktop-context-menu.mov |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, left one small comment 🛸
import useWindowDimensions from '@hooks/useWindowDimensions'; | ||
import type FocusTrapProps from './FocusTrapProps'; | ||
|
||
let activeRouteName = ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need activeRouteName
variable outside the component? Can't we just use, for example, useRef?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This variable is shared between instances of FocusTrap
component
🚨 Hey, just wanted to let you know that I found an issue while testing PR #42772, after PR author merged latest main. The issue came from the latest main which leads me to think that it might be caused by this PR which was just merged but not yet deployed to staging / prod. To confirm this I checked-out to a few commits before this one ( e.g.
|
Just my opinion: Do we need to put additional focustrap in baseModal? |
🚀 Deployed to production by https://github.com/mountiny in version: 1.4.83-3 🚀
|
Pinged in Slack too, but this might be causing an issue with the debug modal - #43897 . Let me know what you think! |
Coming from #43664, there was a regression caused by the focus trap that resulted in the sign in page scrolling to bottom when signing in from a public room. |
focusTrapOptions={{ | ||
trapStack: sharedTrapStack, | ||
allowOutsideClick: true, | ||
fallbackFocus: document.body, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should disable the initial focus to prevent default selection on popup menus.#43659
Hi team. Coming from #43713, there was an issue that the workspace switcher has a blue border after login in mWeb. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coming from #45629:
There's one more case of modal (EmojiPicker) to be wrapped with FocusTrapForModal.
This PR caused #43719, a detailed RCA can be found in this proposal: #43719 (comment) |
/> | ||
</RootStack.Navigator> | ||
</View> | ||
<FocusTrapForScreens> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adamgrzybowski Why do we have FocusTrapForScreens
here if each child screen already has a screenwrapper containing it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wildan-m hello, I also worked on this PR so I can answer. The reason is that FullScreenNavigator
can display two screens, for example:
In this case we have to disable FocusTrap
which is rendered by ScreenWrapper
. Otherwise we would have trap active only in red screen or blue screen. FocusTrap
over navigator allows us to trap focus in both visible screens.
You can see screens with disabled focus trap in src/components/FocusTrap/WIDE_LAYOUT_INACTIVE_SCREENS.ts
file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw are you working on something connected? Maybe we should put the comment in that place
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jnowakow Thank you for your response. Although I haven't encountered any actual issues yet, I noticed that on smaller screens, when the trap is disabled in the screen wrapper (for some reason), it still traps the focus because the parent container FullScreenNavigator's focus trap exists.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okey, so probably it's desired behaviour
Details
This PR adds focus-trap to fix the problem when the user navigates with tab between elements that are not visible.
Fixed Issues
$ #36476
PROPOSAL: #36476 (comment)
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop