-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Fix Modal onDismiss callback is called too early #2558
Fix Modal onDismiss callback is called too early #2558
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 2618014:
|
Is there any way we can add unit test coverage for this? |
@necolas sorry, I have no clue. If you have any ideas in mind, I can try them. |
Try to create a unit test that reproduces the test case and fails, then show that it passes with your patch. You didn't share a test case for the issue, so I don't know what it takes to reproduce, but it seems like it's related to animations. A unit test combining animation props with onDismiss might surface the issue |
This comment was marked as resolved.
This comment was marked as resolved.
Ignore my previous comment, I think I finally understand what should I do 😅 |
Here is the test that I come up with:
The test is to make sure focusing text input inside |
@necolas hi, what do you think about the above unit test? |
@necolas I've added the unit test that is different from what I posted above. Please kindly check it and let me know if I miss something 🙇 |
@necolas hi, how is the review going? |
Looks good, thanks |
Thanks for the review! |
Description
Currently,
onDismiss
is called right after setting theisRendered
state tofalse
which leads toonDismiss
being called before the modal is completely dismissed. This makes chaining action after the modal is dismissed fails, for example, focusing an input.Test plan
onDismiss
props to the Modal which will focus the text inputCurrently, the 5th step fails and this PR is trying to fix it.
Before:
Screen.Recording.2023-07-17.at.17.21.37.mov
After:
Screen.Recording.2023-07-17.at.17.19.50.mov