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

search field if one country? #1632

Closed
Morbids opened this issue May 23, 2024 · 13 comments
Closed

search field if one country? #1632

Morbids opened this issue May 23, 2024 · 13 comments

Comments

@Morbids
Copy link

Morbids commented May 23, 2024

If you set only one country in onlyCountries, then why display the search field?

@jackocnr
Copy link
Owner

If you're only allowing a single country, then why even let them open the dropdown? I would set allowDropdown to false in this case.

@Morbids
Copy link
Author

Morbids commented May 23, 2024

I have these settings

"allowDropdown":false,
"autoPlaceholder":"off",
"dropdownContainer":null,
"formatOnDisplay":false,
"geoIpLookup":"ipapi",
"initialCountry":"ua",
"nationalMode":false,
"onlyCountries":["ua"],
"countryOrder":[],
"separateDialCode":true,
"useFullscreenPopup":false,
"strictMode":true,
"utilsScript":"utils.js"

@jackocnr
Copy link
Owner

Ok. And so does that solve your problem?

@Morbids
Copy link
Author

Morbids commented May 24, 2024

No
Here's a video https://watch.wave.video/kBRwJuGj7mFL1M2h

@jackocnr
Copy link
Owner

separateDialCode requires the dropdown, so it forces allowDropdown to be true. If you want to have allowDropdown: false, you'll need to set separateDialCode: false.

@Morbids
Copy link
Author

Morbids commented May 24, 2024

If separateDialCode is set to false, then the country flag is moved to the other side of the field and the country code disappears.
https://watch.wave.video/EBlOELc5SwKfF1Ks

@jackocnr
Copy link
Owner

Yes, that is how allowDropdown=false works.

From the readme:

if showFlags is enabled we display the selected flag on the right instead because it is just a marker of state

@Morbids
Copy link
Author

Morbids commented May 24, 2024

I understand it.
Maybe then at least leave the country code where it was, otherwise it will be deleted...

@jackocnr
Copy link
Owner

jackocnr commented May 24, 2024

otherwise it will be deleted

Are you concerned that the user will type their international dial code, and then delete it? Why would they do that?

Please can you describe the precise situation you're concerned about, breaking it down into simple steps, from when the plugin is first initialised, and the input is empty.

@Morbids
Copy link
Author

Morbids commented May 24, 2024

When registering a user, if he does not enter the country code (no matter what country), it will not be possible to send an SMS message to the user. Because the SMS gateway requires the country code and the number itself. Not all users enter the country code themselves; most enter the phone number as usual (for example, 0971234567) and it is necessary that the country code already exists.

The question is completely different - is a search field necessary if there is 1 country, or 2 countries, or 3 countries, etc., until how many countries are visible at once in the drop-down list? If they are already visible in the list and there is no need to search there, well, this is purely my opinion. And if there are more countries than are immediately visible in the open list, then the search field is already needed...

@jackocnr
Copy link
Owner

if he does not enter the country code (no matter what country), it will not be possible to send an SMS message to the user

This is actually incorrect. It's enough for the user to enter their number in national format (without the international dial code), and then if you use getNumber, it will give you the full international number (including the international dial code). This is actually how the plugin is designed to work, which is why we show a national number placeholder by default, to encourage the user to do just this. Note that getNumber requires the utils script to be loaded - see readme on how to load this.

The question is completely different - is a search field necessary if there is 1 country, or 2 countries, or 3 countries, etc.,

Sure. Thanks for raising the question. For me, this is not something that should be decided by the plugin - it should be up to the dev to decide how they want this to work depending on their situation (e.g. it might depend on how many countries you can see at once in the dropdown etc, depending on their custom CSS), so this would require a new option to control it, and in my opinion, this is such an edge case that it's not worth implementing this right now. Especially in your case, where there is only 1 country, it doesn't make any sense to have a dropdown at all.

@jackocnr
Copy link
Owner

Upon further consideration, if you only want to show say 2-10 countries, then it makes sense to allow the dropdown, but remove the search feature. So I propose we re-add the countrySearch option, which decides if we show the search box or not (as well as the auto-focus functionality), and defaults to true. It should also be forced to true when separateDialCode is true, as that depends on the search feature. I don't have time to implement this myself right now, but I would be open to a pull request.

@jackocnr
Copy link
Owner

I've re-added the countrySearch option in v23.4.0

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

No branches or pull requests

2 participants