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

feat(SelectCountry): use autocomplete instead of dropdown #3023

Merged
merged 3 commits into from
Dec 8, 2023

Conversation

tujoworker
Copy link
Member

@tujoworker tujoworker commented Dec 7, 2023

With that change we support browser auto-fill and much quicker UX search ability. Also, users can search in both/all locales at the same time.

Fixes #2993

Copy link

vercel bot commented Dec 7, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
eufemia ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 8, 2023 0:29am

Copy link

codesandbox-ci bot commented Dec 7, 2023

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit eef5224:

Sandbox Source
eufemia-starter Configuration

With that change we support browser auto-fill and much quicker search ability. Also, users can search in all locales.
Copy link
Contributor

@joakbjerk joakbjerk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! 🫶

@langz
Copy link
Contributor

langz commented Dec 8, 2023

Done some quick testing at https://eufemia-git-feat-select-country-autocomplete-eufemia.vercel.app/uilib/extensions/forms/feature-fields/SelectCountry/demos/ :

Could the "autocomplete/dropdown list" match the width of the "input field"?

Screen.Recording.2023-12-08.at.10.52.18.mov

@langz
Copy link
Contributor

langz commented Dec 8, 2023

Done some quick testing at https://eufemia-git-feat-select-country-autocomplete-eufemia.vercel.app/uilib/extensions/forms/feature-fields/SelectCountry/demos/ :

Seems like the search functionality doesn't work as expected, when searching for "ch" I get a lot of results that I don't understand why I get.

Screen.Recording.2023-12-08.at.10.54.09.mov

@langz
Copy link
Contributor

langz commented Dec 8, 2023

Done some quick testing at https://eufemia-git-feat-select-country-autocomplete-eufemia.vercel.app/uilib/extensions/forms/feature-fields/SelectCountry/demos/ :

Should the search result be updated when removing characters from an existing search or selected country?

In this video you can see that "sa" as a search gives result initially, but after selecting "saudi-arabia" and when removing characters from "saudi-arabia" so that it gets to "sa", it does not give the same results.

Screen.Recording.2023-12-08.at.10.56.54.mov

@tujoworker
Copy link
Member Author

tujoworker commented Dec 8, 2023

Nice findings! Regarding the ch is because we add the English names too. But I think we should then remove it, and use a different approach regarding the autofill feature 👍

And regarding "saudi-arabia" – it should still filter as before. You may press enter or down arrow to open it again.

@langz
Copy link
Contributor

langz commented Dec 8, 2023

Nice findings! Regarding the ch is because we add the English names too. But I think we should then remove it, and use a different approach regarding the autofill feature 👍

And regarding "saudi-arabia" – it should still filter as before. You may press enter or down arrow to open it again.

In regards to the 'ch'-issue, could we only search in the locale used?
So when searching for "ch" in norwegian locale, we would not get "china" as a result?

@tujoworker
Copy link
Member Author

yes. The latest commit does ensure that 👍

@tujoworker tujoworker force-pushed the feat/select-country-autocomplete branch from 51a8620 to 03d69b2 Compare December 8, 2023 11:32
@langz
Copy link
Contributor

langz commented Dec 8, 2023

yes. The latest commit does ensure that 👍

Great 👏
I'll try to test it once more then, when the preview is rebuilt 🏎️

@langz
Copy link
Contributor

langz commented Dec 8, 2023

Is this a potential issue, do we need to handle if the value is a the ISO code of a country that's not in the given countries value? Or maybe I've just created a strange case that we don't have to handle or provide support for?

Like this:

  <Field.SelectCountry
      countries="Nordic"
      value="AL" //Albania(not in the Nordics)
      onChange={(value) => console.log('onChange', value)}
/>

CSB

@langz
Copy link
Contributor

langz commented Dec 8, 2023

I'm not sure if this is a problem or not, just an observation, but I feel like it takes quite long time to open the autocomplete, could be because of the number of countries(since there's so many) and because of that there's no way around the "delay", or perhaps it's related to something else, not sure. Just wanted to report:

Screen.Recording.2023-12-08.at.14.39.00.mov

But compared to the "old selectcountry" vs. "the new selectcountry" it's noticable.

Or perhaps ignore this, now when I retested I did not feel like the difference was too big, but in my initial test, it somehow took quite longer to open 🤔

@tujoworker tujoworker merged commit 0f2990c into main Dec 8, 2023
10 checks passed
@tujoworker tujoworker deleted the feat/select-country-autocomplete branch December 8, 2023 13:54
@langz
Copy link
Contributor

langz commented Dec 8, 2023

The description says that it "Fixes #2993", is that correct, or perhaps this is "just the start of fixing #2993"?.

As far as I understand, the component still only returns the ISO value of the selected country, and does not have the possibility yet to return more/different properties/keys/values, like "country name", etc. Which was how I interpreted the issue #2993

tujoworker added a commit that referenced this pull request Dec 11, 2023
Like in PR #3023 and since they share so many things, we move the shared
code into the SelectCountry component.

---------

Co-authored-by: Anders <[email protected]>
tujoworker pushed a commit that referenced this pull request Dec 12, 2023
## [10.15.0](v10.14.0...v10.15.0) (2023-12-12)

### 📝 Documentation

* **Card:** adds horizontal fields example ([#2907](#2907)) ([661db7a](661db7a))
* **FAQ:** change version of yarn to v4 ([#2944](#2944)) ([5151fd9](5151fd9))
* **FAQ:** removes stylelint as dependency issue ([#2943](#2943)) ([64ffd13](64ffd13))
* **Field.SelectCountry:** select component -> selection component ([#3003](#3003)) ([b098c6b](b098c6b))
* **FormLabel:** document disabled property ([#3004](#3004)) ([d276bf6](d276bf6))
* **Layout:** fix import of ux-layout-spacing.png ([#2921](#2921)) ([910bcb4](910bcb4))
* **Number:** add info about when to use and not to use ([#2955](#2955)) ([55b3447](55b3447))
* **SelectCountry:** replace bar as value in examples ([#2990](#2990)) ([8fd9f0e](8fd9f0e))

### 🐛 Bug Fixes

* **Autocomplete:** enhance reactivity by value change from outside ([#2922](#2922)) ([e4fd9f9](e4fd9f9))
* **Card:** add support for small screen sizes ([#3051](#3051)) ([62daa1a](62daa1a))
* **DatePicker:** renders mask_placeholder from locale w/o provider ([#2947](#2947)) ([b522bd7](b522bd7))
* **Dropdown:** error message when passing a function to innerRef ([#2932](#2932)) ([c362a4a](c362a4a))
* **Expiry:** correct class placement and CSS specificity issue ([#2915](#2915)) ([ae1154d](ae1154d)), closes [#2914](#2914)
* **FieldBlock:** fix support for stretch alignment ([#2913](#2913)) ([2fdbd4b](2fdbd4b)), closes [#2907](#2907)
* **FormLabel:** don't apply margin-right when no content was given ([#2927](#2927)) ([057f957](057f957))
* **forms:** Fix bug on replacing error message values ([#2971](#2971)) ([b24ddb5](b24ddb5))
* **forms:** Fix data context provider path and error state handling ([#2926](#2926)) ([01a01f4](01a01f4))
* **GlobalStatus:** remove z-index to enhance flexibility ([#2952](#2952)) ([13a9d6e](13a9d6e)), closes [/github.com/dnbexperience/eufemia/commit/1fb638b12df290533e6a89e7f8135a7e23c0797e#diff-4d582f82c1661d8de20042e6e65250a4d2710c2b31f8955fcd6eda14097a0b4](https://github.com/dnbexperience//github.com/dnbexperience/eufemia/commit/1fb638b12df290533e6a89e7f8135a7e23c0797e/issues/diff-4d582f82c1661d8de20042e6e65250a4d2710c2b31f8955fcd6eda14097a0b4)
* **Hr:** remove overflow causing a scrollbar ([#2945](#2945)) ([dc989ff](dc989ff))
* **PhoneNumber:** ensure correct alignment on smaller screens ([#2957](#2957)) ([ae9913b](ae9913b))
* **PhoneNumber:** return country code only when a number is given ([#2920](#2920)) ([5b1a9b0](5b1a9b0)), closes [#2922](#2922) [#2923](#2923)
* **RadioGroup:** omit rendering label when not given ([#2928](#2928)) ([693f9d4](693f9d4))
* **Selection:** correctly link id with label ([#2911](#2911)) ([71ad30d](71ad30d)), closes [#2842](#2842)
* **ToggleButtonGroup:** omit rendering label when not given ([#2929](#2929)) ([26f683e](26f683e))

### ✨ Features

* **Accordion:** new filled variant + style refactoring ([#2896](#2896)) ([a4c1fb0](a4c1fb0))
* add support for functional refs to various form components ([#2946](#2946)) ([cecad75](cecad75))
* **Breadcrumb:** correct gap between items and fix overlapping focus ring ([#2917](#2917)) ([6252458](6252458))
* **Button, Anchor:** fix launch icon for _blank button links ([#2930](#2930)) ([37a65dc](37a65dc))
* **Checkbox:** Sbanken styling ([#2904](#2904)) ([b2dbd44](b2dbd44)), closes [#2888](#2888)
* **Currency:** add automatic locale and alignment support ([#2956](#2956)) ([3c64d4d](3c64d4d))
* **forms:** include styles by default ([#2918](#2918)) ([e2f4c1e](e2f4c1e))
* **MultiInputMask:** Add stretch property ([#2914](#2914)) ([706beb3](706beb3))
* **PaymentCard:** adds card_status unknown ([#2934](#2934)) ([a36ffa7](a36ffa7))
* **PhoneNumber:** add `pattern` property ([#2962](#2962)) ([86cb6e0](86cb6e0))
* **PhoneNumber:** add filter for showing e.g. only Scandinavia countries ([#2959](#2959)) ([995c43d](995c43d))
* **PhoneNumber:** add prioritized sort option ([#3034](#3034)) ([5fe0e41](5fe0e41)), closes [#3023](#3023)
* **PhoneNumber:** add property `omitCountryCodeField` ([#2961](#2961)) ([4a3c7e2](4a3c7e2))
* **PhoneNumber:** remove structure and format when number is not +47 ([#2958](#2958)) ([56e2f08](56e2f08))
* **Section:** add dropShadow support ([#3053](#3053)) ([040a92b](040a92b))
* **SelectCountry:** use autocomplete instead of dropdown ([#3023](#3023)) ([0f2990c](0f2990c)), closes [#2993](#2993)
* **Switch:** Sbanken styling ([#2939](#2939)) ([46c5506](46c5506))
* **ToggleButton:** Sbanken styling ([#2936](#2936)) ([5370376](5370376)), closes [#2931](#2931) [#2904](#2904) [#2888](#2888)
* Updated Sbanken theming + improved screenshot test coverage for Radio+Checkbox ([#2931](#2931)) ([e42c81e](e42c81e))
@tujoworker
Copy link
Member Author

🎉 This PR is included in version 10.15.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

feat(SelectCountry): return the full country object when selecting a country
3 participants