-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
[Awaiting Payment 26th Sept] [$250] Selecting a filter and using keyboard return on the filter confirmation screen ends up clearing filters. #48108
Comments
Triggered auto assignment to @trjExpensify ( |
Job added to Upwork: https://www.upwork.com/jobs/~01e1f39a3a6d7c0f4a |
Triggered auto assignment to Contributor-plus team member for initial proposal review - @alitoshmatov ( |
This is related to focus trap. It seems like the top back button is selected when |
Edited by proposal-police: This proposal was edited at 2024-08-27 18:38:39 UTC. ProposalPlease re-state the problem that we are trying to solve in this issue.Focus is set on the back button when navigating to the filter page using keyboard What is the root cause of that problem?when the filter page is first rendered, the focus trap keeps the focus on the back button and doesn't move to the confirm button. we solved this issue in the submit report confirmation page by bluring the active element so the focus moves from the back header to the button after the timeout: App/src/components/MoneyRequestConfirmationList.tsx Lines 815 to 825 in 735101a
What changes do you think we should make in order to solve the problem?we should do the same in the filter page to keep both flows consistent and don't introduce breaking changes to the focus trap logic. Optionalthis logic can be moved to a hook and used when needed to avoid code duplication resultScreen.Recording.2024-08-27.at.8.47.38.PM.mov |
ProposalPlease re-state the problem that we are trying to solve in this issue.
App/src/components/MoneyRequestConfirmationList.tsx Lines 815 to 825 in e5b6cef
What is the root cause of that problem?Due to the focus trap the focus is set to the first focus element instead of the submit button. What changes do you think we should make in order to solve the problem?
const focusTimeoutRef = useRef<NodeJS.Timeout | null>(null);
useFocusEffect(
useCallback(() => {
if (pressOnEnter) {
focusTimeoutRef.current = setTimeout(() => {
InteractionManager.runAfterInteractions(() => {
blurActiveElement();
});
}, CONST.ANIMATED_TRANSITION);
}
return () => {
if (!focusTimeoutRef.current) {
return;
}
clearTimeout(focusTimeoutRef.current);
};
}, [pressOnEnter]),
); What alternative solutions did you explore? (Optional)Result |
Edited by proposal-police: This proposal was edited at 2024-08-28 08:54:02 UTC. ProposalPlease re-state the problem that we are trying to solve in this issue.When entering a search filter on the advanced search page, pressing What is the root cause of the problem?When the screen is mounted, the focus trap sets the App/src/components/FocusTrap/FocusTrapForScreen/index.web.tsx Lines 49 to 58 in ac5ee2e
Since the document's What changes do you think we should make in order to solve the problem?The focus trap already listens for the focus event and checks whether the focused element is within the element to which it is attached (in this case, within the screen). It will automatically move the focus inside the screen if it is outside. For example, when the user presses the We can disable the App/src/components/FocusTrap/FocusTrapForScreen/index.web.tsx Lines 44 to 45 in 59741d8
we could add an App/src/components/FocusTrap/FocusTrapForScreen/index.web.tsx Lines 49 to 59 in 59741d8
we should always set it to The focus trap already listens for the focus event and will check whether the focused element is inside the element to which it is attached (in this case, inside the screen) and will automatically move the focus inside the screen if it is outside. The code change (in legacy mode, to test set focusTrapOptions={{
+ onActivate: () => {
+ document?.activeElement?.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;
+ return false;
},
setReturnFocus: (element) => {
+ return false;
- if (document.activeElement && document.activeElement !== document.body) {
- return false;
- }
- return element;
},
...(focusTrapSettings?.focusTrapOptions ?? {}),
}} What alternative solutions did you explore? (2)On other pages, we use
etc.. We could also use it for const { inputCallbackRef } = useAutoFocusInput(); Then, in: App/src/pages/Search/AdvancedSearchFilters.tsx Lines 316 to 317 in 3e5da78
we add |
📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸 |
@abzokhattab Thank you for your proposal, your RCA is correct and solution does solve the issue |
@Krishna2323 Thank you for your proposal, I think you solution is great since it addresses all the instances of this issue |
@tsa321 Thank you for your proposal, I think we should not change current logic of focus trap |
I agree that the other proposal addresses the issue in other components as well, but I believe it could be a risky change since it's used extensively so we should be careful when modifying the focus. I'm concerned that this could introduce regressions in the I think a safer option would be to create a hook and call it when needed. However, I'm open to hearing your thoughts on this, @alitoshmatov, @trjExpensify, @luacmartins. |
ProposalPlease re-state the problem that we are trying to solve in this issue.Avoid initial focus trap element while container includes button has an enter event listener What is the root cause of that problem?We only have condition isFocusedElementInsideContainer to prevent set initial focus but at AdvancedSearchFilters screen we don't have any focused element so the initial focus will be set to the first focusable element in the screen container. What changes do you think we should make in order to solve the problem?To prevent this issue from occurring in other places, we should add a new condition that prevents setting the initial focus when the container includes a button with an enter event listener. const isFocusedElementInsideContainer = !!focusTrapContainers?.some((container) => container.contains(document.activeElement));
+ const isButtonHasEnterListener = !!focusTrapContainers?.some((container) => !!container.querySelector('button[data-listener="ENTER"]'));
+ if (isFocusedElementInsideContainer || isButtonHasEnterListener) {
- if (isFocusedElementInsideContainer) {
return false;
} Update Button component to add a new attribute <PressableWithFeedback
+ dataSet={{
+ listener: !!pressOnEnter ? 'ENTER' : undefined,
+ }}
ref={ref}
onPress={(event) => { What alternative solutions did you explore? (Optional) |
Proposalupdated |
I think we should go with @abzokhattab 's proposal and solve it for current issue. C+ reviewed 🎀 👀 🎀 |
Current assignee @luacmartins is eligible for the choreEngineerContributorManagement assigner, not assigning anyone new. |
@alitoshmatov, any comments on my proposal? It will fix all the pages with Monosnap.screencast.2024-09-04.23-47-07.mp4 |
I think we should find an overall solution to prevent initialFocus early when the screen has a focused element or a button listening for the enter event, instead of relying on trigger |
I agree that we should look at a holistic solution for other pages as well, so we don't end up with 42 different ways to solve the same problem. Let's fix the root cause. |
@trjExpensify, @luacmartins, @alitoshmatov Eep! 4 days overdue now. Issues have feelings too... |
💯 agree, anyone got thoughts on a proposal for that? |
@alitoshmatov How about my proposal? It can prevent the initial focus early, rather than deactivating the focused element. |
@trjExpensify @luacmartins @alitoshmatov this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks! |
@trjExpensify, @luacmartins, @alitoshmatov Eep! 4 days overdue now. Issues have feelings too... |
I think @suneox 's proposal makes sense now. It goes to source of the problem, and will make sure focus is not reset into first focusable element when there is a button with @luacmartins What do you think? |
Agreed, let's do it. |
📣 @alitoshmatov 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app! |
📣 @suneox 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app! Offer link |
This comment has been minimized.
This comment has been minimized.
PR on prod, updated the title to reflect the payment hold. |
@suneox @trjExpensify @luacmartins @alitoshmatov this issue is now 4 weeks old, please consider:
Thanks! |
Go away, melvin. |
Payment summary as follows:
Paid, closing! |
If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!
Version Number: 9.0.25-7
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: @JmillsExpensify
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1724762642354929
Action Performed:
Expected Result:
No filters are cleared
Actual Result:
All filters are cleared, nothing happens.
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Screenshots/Videos
Recording.496.mp4
Add any screenshot/video evidence
View all open jobs on GitHub
Upwork Automation - Do Not Edit
Issue Owner
Current Issue Owner: @trjExpensifyThe text was updated successfully, but these errors were encountered: