-
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
[$500] Web - Navigating to Search by keyboard shortcut when the "Update Workspace currency to USD" Modal is open Does not close the modal #27277
Comments
Triggered auto assignment to @anmurali ( |
Job added to Upwork: https://www.upwork.com/jobs/~0152ef93375eec0d1f |
Bug0 Triage Checklist (Main S/O)
|
Triggered auto assignment to @strepanier03 ( |
Triggered auto assignment to Contributor-plus team member for initial proposal review - @situchan ( |
ProposalProblem StatementWhen user is Navigated to search using keyboard shortcuts, the attachement Modal is not closed and navigation gets broken. Root CauseThe root cause is when keyboard shortcut is triggered we call Modal.close(() => callback), here modal.close is dependent on the onClose prop which we pass in Modal component. But in this case we have 2 Modals in stack, so variable we are using to store onClose prop is getting overridden by second ConfirmModal onClose prop (which is null if modal not visble) SolutionConditionally rendering the props of the ConfirmModal in WorkspaceInitialPage based on which modal is visible and having only one modal in the stack would solve the issue. <ConfirmModal
title={(isDeleteModalOpen ? props.translate('workspace.common.delete') : null )|| (isCurrencyModalOpen ? props.translate('workspace.bankAccount.updateToUSD') : null)}
isVisible={isDeleteModalOpen || isCurrencyModalOpen}
onConfirm={isDeleteModalOpen ? confirmDeleteAndHideModal : confirmCurrencyChangeAndHideModal}
onCancel={isDeleteModalOpen ? () => setIsDeleteModalOpen(false) : () => setIsCurrencyModalOpen(false)}
prompt={props.translate('workspace.common.deleteConfirmation')}
confirmText={isDeleteModalOpen ? props.translate('workspace.common.delete') : props.translate('workspace.bankAccount.updateToUSD')}
cancelText={props.translate('common.cancel')}
danger
/> Alternative SolutionAs this problem can be solved by conditionally rendering the ConfirmModal. There is a downside to the approach we are following as explained in root cause, we can only have one modal in Stack at a time. otherwise keyboard shortcuts fails Pseudo Code:
|
ProposalPlease re-state the problem that we are trying to solve in this issue.Web - Navigating to Search by keyboard shortcut when the "Update Workspace currency to USD" Modal is open Does not close the modal What is the root cause of that problem?We have 2 modals in WorkspaceInitialPage App/src/pages/workspace/WorkspaceInitialPage.js Lines 266 to 276 in 2bf7bf4
When isCurrencyModalOpen is true, both 2 onCancel callback are re-created, that causes this hook triggers App/src/components/Modal/BaseModal.js Lines 77 to 82 in 2bf7bf4
When users enter
but at that time, the closeModal is What changes do you think we should make in order to solve the problem?The problem here is because the modal re-renders unexpectedly. When In order to archive that, we should wrap 2 onClose callbacks into useCallback hook
ResultScreen.Recording.2023-09-13.at.14.46.58.mov |
Triggered auto assignment to @marcaaron, see https://stackoverflow.com/c/expensify/questions/7972 for more details. |
Hmm I am really unsure sure about this proposal. It seems like there is something wrong with the implementation of the modal component itself. First, why is it overwriting the callback? That seems like a strange hack to me. @tienifr Can you try to put the problem into your own words now that you've investigated it? I don't think repeating the title of the issue is sufficient. It feels like there is some kind of deeper design flaw related to modals if this bug can easily be introduced again in the future. |
@situchan please find a suitable proposal and tag me back in when this is ready for review. |
@marcaaron I think we don't have any flaws in the modal implementation There's only one opened modal at a time. Here's the normal flow:
So we can easily realize that we can not face with race condition here But in step 2, when isCurrencyModalOpen is set to true, onCancel callback of DeleteModal is also re-created to the new one
So that triggers this hook App/src/components/Modal/BaseModal.js Lines 77 to 82 in 2bf7bf4
because isVisible of DeleteModal is false -> onClose is set to null Note: We just face the problem in the component that has more than 1 modal, so I think the best way to fix it is wrap onCancel into useCallback hook Please let me know if there're some unclear points. Thanks |
@marcaaron Do you agree with this #27277 (comment)? |
Honestly, it's all kind of unclear.
I'm not realizing it. Can you walk us through it? You are describing the different states in the code. But not really describing why it works the way that it does. It particular, I find it strange that we are losing the callback and why |
@marcaaron I can't reproduce, it's fixed by other PR, so we can close this one |
Not reproducible really. @tienifr do you know which PR fixed this? |
We good to close this one out then? |
yes |
Gotcha, thanks for confirming. Closing now. |
If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!
Action Performed:
Expected Result:
Modal should close before navigation.
Actual Result:
Modal Remains open and app navigates to search.
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Version Number: 1.3.68.12
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
Notes/Photos/Videos: Any additional supporting documentation
Screen.Recording.2023-09-09.at.5.52.35.PM.mov
Recording.4419.mp4
Expensify/Expensify Issue URL:
Issue reported by: @ishpaul777
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1694263008212129
View all open jobs on GitHub
Upwork Automation - Do Not Edit
The text was updated successfully, but these errors were encountered: