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
willBlur/didBlur events fired when trying to navigate to the current tab #3511
Comments
Hey, please provide a repro on snack.expo.io |
You help me understand my issue was not so simple. I made a snack and edited the issue. |
So the issue you have is that you're already on "Settings" screen and try to navigate to the same screen again, then you get "willBlur", right? I can repro it on snack. It fires only the first time I try to navigate though. cc @ericvicenti |
That's right. The use case may seem odd but i discovered this behaviour trying to implement a custom tab bar. When i press a tab i navigate to it but i had no guard to prevent navigation to the current tab. Anyway in that specific use case, the screen blurs but no other screen is focused though i am on a screen actually. |
repros on 2.0 -- @ericvicenti https://snack.expo.io/Hy_mKLApG |
We encountered this recently when using StackNavigator. Repro using 2.0: https://snack.expo.io/BkSVTgJCf |
2.0.1 should resolve these issues, with #4168 (edit - confirmed: i tested both of those snacks against 2.0.1 and they work as expected, thanks for the repros!) |
Current Behavior
I have a TabNavigator and i use navigation.addListener to catch events like willBlur or didBlur.
When i try to navigate to the same tab i am actually on willBlur and didBlur events are triggered.
I want to load data on focus event and clean data on blur event. Triggering a blur event when tab is not changed is difficult to handle.
Expected Behavior
Blur events should be fired only when tab is changed or focus events should follow blur events in this specific case.
How to reproduce
There is a snack : https://snack.expo.io/@michaelborde/react-navigation-willblur
Environment
Thoughts
I agree it is not common to navigate to the current screen but i discovered this behaviour with a specific use case. Feel free to close this issue if you think it's irrelevant. For the moment my workaround is to check wether i try to navigate to the current screen or not.
The text was updated successfully, but these errors were encountered: