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

Distinguishing onCountrySelected triggers for CountryDropdown (user choosing versus initialCountryCode triggering) #122

Closed
RobHoman opened this issue Mar 2, 2023 · 2 comments

Comments

@RobHoman
Copy link

RobHoman commented Mar 2, 2023

I noticed that using initialCountryCode for the CountryDropdown will cause onCountrySelected to trigger. I need a particular app behavior to respond only when onCountrySelected is triggered due to the user interaction, but I'm struggling to find a clean way to make the distinction.

Specifically, I want to move the focus to the next field in the form - the phone number text field - after the user selects the country. But since this triggers due to the initialCountryCode setting, my form is immediately focusing on the phone input, which is undesirable when the form is first loaded onto the screen.

If I could distinguish this somehow, that would solve my issues. Or, maybe you have thoughts on how better to integrate the CountryCode dropdown with the FocusNode conventions of Flutter and the conventions of Flutter forms?

@RobHoman RobHoman changed the title Distinguishing onCountrySelected triggers for CountryDropdown (user choosing versus initial Distinguishing onCountrySelected triggers for CountryDropdown (user choosing versus initialCountryCode triggering) Mar 2, 2023
@caseyryan
Copy link
Owner

CountryDropdown is there as an example. You can easily take it as a base and write your own widget. But I think that's a good point and I'll add the way to distinguish user selection from the default one

@caseyryan
Copy link
Owner

Fixed. Added a parameter called triggerOnCountrySelectedInitially. Just pass false and it will not be triggered on first build

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

No branches or pull requests

2 participants