From f13294fadb94e51196e4837c83dea5b99179feac Mon Sep 17 00:00:00 2001 From: Jason Barnabe Date: Fri, 12 Jun 2020 13:29:34 -0500 Subject: [PATCH 1/2] Also list priority countries in their normal place alphabetically Having priority countries at the top is good, but if the dropdown is initialized with a different default, and the user wants to switch to one of those priority countries, they may not think to look at the top of the list. This change makes it so priority countries are also listed in their normal alphabetical spot in addition to being at the top of the list. --- lib/localized_country_select.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/localized_country_select.rb b/lib/localized_country_select.rb index bc3a9bd..a3d1978 100644 --- a/lib/localized_country_select.rb +++ b/lib/localized_country_select.rb @@ -80,10 +80,8 @@ def localized_country_options_for_select(selected = nil, priority_countries = ni if priority_countries country_options += options_for_select(LocalizedCountrySelect::priority_countries_array(priority_countries, options), selected) country_options += "\n".html_safe - return country_options + options_for_select(LocalizedCountrySelect::localized_countries_array(options) - LocalizedCountrySelect::priority_countries_array(priority_countries, options), selected) - else - return country_options + options_for_select(LocalizedCountrySelect::localized_countries_array(options), selected) end + return country_options + options_for_select(LocalizedCountrySelect::localized_countries_array(options), selected) end alias_method :country_options_for_select, :localized_country_options_for_select From 373668339733c4676d1333e578fc93d12685ac4f Mon Sep 17 00:00:00 2001 From: Jason Barnabe Date: Fri, 12 Jun 2020 14:01:37 -0500 Subject: [PATCH 2/2] Don't double select --- lib/localized_country_select.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/localized_country_select.rb b/lib/localized_country_select.rb index a3d1978..19cf6f3 100644 --- a/lib/localized_country_select.rb +++ b/lib/localized_country_select.rb @@ -80,6 +80,7 @@ def localized_country_options_for_select(selected = nil, priority_countries = ni if priority_countries country_options += options_for_select(LocalizedCountrySelect::priority_countries_array(priority_countries, options), selected) country_options += "\n".html_safe + selected = nil if priority_countries.include?(selected) end return country_options + options_for_select(LocalizedCountrySelect::localized_countries_array(options), selected) end