diff --git a/js/apps/account-ui/test/personal-info/personal-info.spec.ts b/js/apps/account-ui/test/personal-info/personal-info.spec.ts index 41c785c802..9c84f2380d 100644 --- a/js/apps/account-ui/test/personal-info/personal-info.spec.ts +++ b/js/apps/account-ui/test/personal-info/personal-info.spec.ts @@ -60,6 +60,32 @@ test.describe("Personal info with userprofile enabled", async () => { await expect(page.getByText("EspaƱol")).toHaveCount(1); }); + test("render long select options as typeahead", async ({ page }) => { + await login(page, user, "jdoe", realm); + + await page.getByText("Alternate Language").click(); + await page.waitForSelector("text=Italiano"); + + await page.locator("*:focus").press("Control+A"); + await page.locator("*:focus").pressSequentially("S"); + await expect(page.getByText("Italiano")).toHaveCount(0); + expect(page.getByText("Suomi")).toBeVisible(); + expect(page.getByText('Create "S"')).not.toBeVisible(); + }); + + test("render long list of locales as typeahead", async ({ page }) => { + await login(page, user, "jdoe", realm); + + await page.locator("#locale").click(); + await page.waitForSelector("text=Italiano"); + + await page.locator("*:focus").press("Control+A"); + await page.locator("*:focus").pressSequentially("S"); + await expect(page.getByText("Italiano")).toHaveCount(0); + expect(page.getByText("Suomi")).toBeVisible(); + expect(page.getByText('Create "S"')).not.toBeVisible(); + }); + test("save user profile", async ({ page }) => { await login(page, user, "jdoe", realm); diff --git a/js/apps/account-ui/test/personal-info/user-profile.json b/js/apps/account-ui/test/personal-info/user-profile.json index 570bcc4e45..ecf8618d3d 100644 --- a/js/apps/account-ui/test/personal-info/user-profile.json +++ b/js/apps/account-ui/test/personal-info/user-profile.json @@ -223,6 +223,71 @@ "email": {} }, "group": "group" + }, + { + "name": "alternatelang", + "displayName": "Alternate Language", + "validations": { + "options": { + "options": [ + "ar", + "ca", + "cs", + "de", + "en", + "es", + "fr", + "hu", + "fa", + "it", + "ja", + "lt", + "nl", + "no", + "pl", + "pt", + "ru", + "sk", + "sv", + "th", + "tr", + "uk", + "zh", + "fi" + ] + } + }, + "annotations": { + "inputType": "select", + "inputOptionLabels": { + "ar": "${locale_ar}", + "ca": "${locale_ca}", + "cs": "${locale_cs}", + "de": "${locale_de}", + "en": "${locale_en}", + "es": "${locale_es}", + "fr": "${locale_fr}", + "hu": "${locale_hu}", + "fa": "${locale_fa}", + "it": "${locale_it}", + "ja": "${locale_ja}", + "lt": "${locale_lt}", + "nl": "${locale_nl}", + "no": "${locale_no}", + "pl": "${locale_pl}", + "pt": "${locale_pt}", + "ru": "${locale_ru}", + "sk": "${locale_sk}", + "sv": "${locale_sv}", + "th": "${locale_th}", + "tr": "${locale_tr}", + "uk": "${locale_uk}", + "zh": "${locale_zh}", + "fi": "${locale_fi}" + } + }, + "permissions": { "view": ["admin", "user"], "edit": ["admin", "user"] }, + "group": "group" } ], "groups": [ diff --git a/js/apps/account-ui/test/realms/user-profile-realm.json b/js/apps/account-ui/test/realms/user-profile-realm.json index 0733c07f1b..7e86519f6e 100644 --- a/js/apps/account-ui/test/realms/user-profile-realm.json +++ b/js/apps/account-ui/test/realms/user-profile-realm.json @@ -200,5 +200,34 @@ } } ], - "identityFederationEnabled": true + "identityFederationEnabled": true, + "internationalizationEnabled": true, + "supportedLocales": [ + "de", + "no", + "fi", + "ru", + "lt", + "lv", + "fr", + "hu", + "zh-CN", + "sk", + "ca", + "sv", + "pt-BR", + "el", + "en", + "it", + "es", + "cs", + "ar", + "ja", + "fa", + "pl", + "da", + "nl", + "tr" + ], + "defaultLocale": "en" } diff --git a/js/libs/ui-shared/src/controls/SelectControl.tsx b/js/libs/ui-shared/src/controls/SelectControl.tsx index 445c9500f4..5662e39348 100644 --- a/js/libs/ui-shared/src/controls/SelectControl.tsx +++ b/js/libs/ui-shared/src/controls/SelectControl.tsx @@ -72,7 +72,9 @@ export const SelectControl = < const lowercasePrefix = prefix.toLowerCase(); return options .filter((option) => - option.toString().toLowerCase().startsWith(lowercasePrefix), + (isString(option) ? option : option.value) + .toLowerCase() + .startsWith(lowercasePrefix), ) .map((option) => ( diff --git a/js/libs/ui-shared/src/user-profile/LocaleSelector.tsx b/js/libs/ui-shared/src/user-profile/LocaleSelector.tsx index 2c9d0cc125..a522a95dd3 100644 --- a/js/libs/ui-shared/src/user-profile/LocaleSelector.tsx +++ b/js/libs/ui-shared/src/user-profile/LocaleSelector.tsx @@ -34,6 +34,7 @@ export const LocaleSelector = ({ label={t("selectALocale")} controller={{ defaultValue: "" }} options={locales} + variant={locales.length >= 10 ? "typeahead" : "single"} /> ); diff --git a/js/libs/ui-shared/src/user-profile/SelectComponent.tsx b/js/libs/ui-shared/src/user-profile/SelectComponent.tsx index 352b14989a..70519354bf 100644 --- a/js/libs/ui-shared/src/user-profile/SelectComponent.tsx +++ b/js/libs/ui-shared/src/user-profile/SelectComponent.tsx @@ -48,8 +48,6 @@ export const SelectComponent = (props: UserProfileFieldProps) => {