country-regions / country-region-selector

Dynamic country and region dropdowns for your forms.
http://country-regions.github.io/country-region-selector/
MIT License
252 stars 115 forks source link

Example 6 & 7 show wrong regions for selected country #50

Closed gricey432 closed 7 years ago

gricey432 commented 7 years ago

Was just checking this library out and noticed an issue with the example, not sure if it's a bug in the library or just in the example.

http://benkeen.github.io/country-region-selector/ Example 6 shows the wrong regions for the listed countries.

screenshot_2017-07-05_13-23-21

benkeen commented 7 years ago

Hmm, thanks @gricey432! Looks fishy. I'll check it out.

gricey432 commented 7 years ago

Looks like example 7 does the same thing

benkeen commented 7 years ago

Yeah. I tinkered with it last night and it was working fine locally. Odd - I'll investigate this weekend. Thanks very much for letting me know, it may well be a bug.

ellenhutchings commented 7 years ago

I just checked it out and this is definitely happening for me too. I noticed that I got different incorrect regions when I switched from United States to Canada. I think the id or whatever field that's being checked to populate the regions to be populated is being messed up somehow.

benkeen commented 7 years ago

Sorry for the wait on this. I see the problem now. Multiple fields on the same page all share the same country source, so targeting index N on a field with whitelisted/blacklisted items won't always target the appropriate country. Let me see what I can do...

benkeen commented 7 years ago

Almost there! I've made a patch, but I need to make it more performant. If I don't get it out tonight I should get a new version done by tomorrow night.