-
Notifications
You must be signed in to change notification settings - Fork 130
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
iOS onChange called twice #140
Comments
|
Sorry, should have said, we're on "0.61.5". |
There are unfortunately too many variations in RN's modal behavior of Would you mind testing these options:
|
Hi, |
That is surprising. |
To break this down:
And our onChange is:
If I don't comment out that line, then our onChange gets called twice, so for instance the document picker dialog opens, closes, then re-opens. If I don't comment out that line, and use 'onModalClose' instead of 'onChange', the behaviour is the same as commenting out the line ie our dialog opens, then immediately closes. If I both comment out the line and use 'onModalClose', the behaviour is the same as above. |
Is it closing after you select an option, or immediately after the modal opens? If you don't want the modal to close upon a selection, use the prop If that's not the case, this is very puzzling. Does |
Yes, it's closing immediately after an option is selected. |
@dx-pranta-bot This modal is designed to close when an option is selected. Since |
@justincrow I re-read your notes and think I understand what I missed earlier. It sounds like you use
PS: What are the values passed to the |
Sorry for the radio silence. If we use Using the When closing the modal selector manually using a ref, the 2nd duplicate callback is again invoked upon the close. In summary, it would seem we always get the duplicate callback regardless of how the selector is closed. Thanks. |
Thanks for the updated notes. Does your Document picker live inside or outside of the modal? It's surprising that the modal state change would cause the picker to close. Perhaps the OS native modal interferes with the native picker. The |
@justincrow |
Some historical context related to this issue: #114 |
I found that first time it call so I did a weird thing:
And it works for me |
Thanks @AlexeyKhmelev for reporting this. Would you mind opening a new issue? It helps with tracking bug fixes. |
This is my solution. Use |
Is there any chance this is going to be fixed? |
Thanks! It works for me. |
Any update on when this is properly fixed? |
Apologies for the late response. Android and iOS native modals behave differently, and changing it for iOS could break Android. However it looks like @AlexeyKhmelev 's check for the empty key field would work. |
Fix has been published in 2.0.5. Please test this on both iOS and Android. |
good catch @glinda93 . Published 2.0.6 to address the key=0 bug. It sounds like there are different causes for the reported issue. Have you been able to debug it? |
The recent change does not use the keyExtractor function thus breaking use cases where the keyExtractor function is used. I just realised that onChanged is not called anymore. |
Sorry about that @aschmitz-wbd . Fix released in 2.0.7 |
Thx a lot for the quick response and fix :) |
Hi, onChange firing twice is still happening for me on iOS 14.3, RN 0.64.2 using release 2.0.7. The onModalClose workaround as suggested by @imginnn is working |
However, onModalClose does not give you the key/label info of the option you selected Update: I see it does in the code, but the typings for this package do not indicate this. Please update your typings/docs |
I just lost part of my day looking for errors in my logic due to onChange behavior being incompletely documented. onModalClose is a more narrowly focused event and works as I expected onChange to behave.
It's definitely triggered by other actions and can result in a double toggle behavior |
Yeah, I have a same problem in my screen. It will diplay a form Modal first and then show a ModalSelector upon. After selecting a option, the onChange is called and close the ModalSelector. When I close the form Modal. The onChange of ModalSelector is called again. It is really annoyed. Changing from onChange to onModalClose does work. Thank for providing this solution. |
Thank for your solution! ** onModalClose** works as expected. |
If anyone stumbles upon this issue... Above proposed solution worked for me. I'm using |
Thank you so much, this works! |
Since version 2, as documented, iOS onChange is called multiple times.
Please could you explain why this decision was made and how to work around it?
The text was updated successfully, but these errors were encountered: