From 652a042a557974b9b5bcfa4a24b4994c46bb52a6 Mon Sep 17 00:00:00 2001 From: "Timothy Z." Date: Wed, 25 Jun 2025 16:59:16 +0300 Subject: [PATCH] fix(Settings): correctly sort without matchingidx --- src/common/useLanguageSorting.ts | 6 ++++-- src/routes/Settings/Player/usePlayerOptions.ts | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/common/useLanguageSorting.ts b/src/common/useLanguageSorting.ts index 44c8927bd..d5969cf76 100644 --- a/src/common/useLanguageSorting.ts +++ b/src/common/useLanguageSorting.ts @@ -22,10 +22,12 @@ const useLanguageSorting = (options: MultiselectMenuOption[]) => { return userLangCode.some((code) => lang?.codes.includes(code)); }); - if (matchingIndex === -1) return options; + if (matchingIndex === -1) { + return [...options].sort((a, b) => a.label.localeCompare(b.label)); + } const matchingOption = options[matchingIndex]; - const otherOptions = options.filter((_, index) => index !== matchingIndex); + const otherOptions = options.filter((_, idx) => idx !== matchingIndex).sort((a, b) => a.label.localeCompare(b.label)); return [matchingOption, ...otherOptions]; }, [options, userLangCode, isLanguageDropdown]); diff --git a/src/routes/Settings/Player/usePlayerOptions.ts b/src/routes/Settings/Player/usePlayerOptions.ts index 383709604..edbce3d24 100644 --- a/src/routes/Settings/Player/usePlayerOptions.ts +++ b/src/routes/Settings/Player/usePlayerOptions.ts @@ -20,7 +20,7 @@ const usePlayerOptions = (profile: Profile) => { const subtitlesLanguageSelect = useMemo(() => ({ options: [ { value: null, label: t('NONE') }, - ...sortedLanguageOptions.sort((a, b) => a.label.localeCompare(b.label)) + ...sortedLanguageOptions ], value: profile.settings.subtitlesLanguage, onSelect: (value: string) => { @@ -109,7 +109,7 @@ const usePlayerOptions = (profile: Profile) => { }), [profile.settings]); const audioLanguageSelect = useMemo(() => ({ - options: sortedLanguageOptions.sort((a, b) => a.label.localeCompare(b.label)), + options: sortedLanguageOptions, value: profile.settings.audioLanguage, onSelect: (value: string) => { core.transport.dispatch({