Skip to content
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

[Android] Fix invoking onSelect / onValueChange without user interaction #504

Conversation

lorenc-tomasz
Copy link
Contributor

@lorenc-tomasz lorenc-tomasz commented Jun 30, 2023

Problems encountered on Android:

  • On initial render the onSelect / onValueChanged event is called without user interaction
  • When initial values changes the the onSelect / onValueChanged event is called without user interaction
  • User cannot select the same element on Android event when selected item on react site is different, e.g. user selects option 1, it fails, and user cannot select the same option to retry the action
  • On Android 8-10 the onWindowFocusChanged (onBlur) event is called before onSelect / onValueChanged event

Solutions:

  • Allow to invoke onSelect / onValueChanged event only when user interaction happened, e.g. when component where opened by user. REMARK: On Android 8 to 10, unfortunately, order of events is broken and onBlur happens before onSelect / onValueChanged event.
  • Allow user to select the same element by invoking the event manually.
  • Make sure that onBlur will be called after onSelect / onValueChanged

Should fix #116, #208, #267 and #503

Sometimes on Android onValueChange is called on initial render or values changes. To fix that we should only call onValueChange when user interaction happens. To ensure that we should invoke onValueChange only when picker options are visible to the user. 
Set onBlur and onFocus events


Change order 


Fix Android < 11 as there events are called in different order


[Android] Allow to select the same item again


Use mOnSelectListener


Properly support Androids 8-10, and 11+ 


Correct value 


Use refs
@lorenc-tomasz
Copy link
Contributor Author

@Naturalclar I have fixed lint issues. No idea about macos building issues.

@lorenc-tomasz lorenc-tomasz changed the title Fix invoking onSelect / onValueChange without user interaction [Android] Fix invoking onSelect / onValueChange without user interaction Jul 4, 2023
@lorenc-tomasz
Copy link
Contributor Author

@Naturalclar Hi, any chance to merge this PR?

@scaralfred
Copy link

Any chance to merge this PR?

@Naturalclar
Copy link
Contributor

Merged this change with lint error fixed in #545 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

onvaluechange fired when the component is initialized (android)
3 participants