Skip to content

Commit dd4c6dd

Browse files
committed
Fix filtering when searching for languages in app-hosted mode (BL-15822)
1 parent 398db1e commit dd4c6dd

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

src/components/appHosted/AppHostedLanguageGroup.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,17 @@ export const AppHostedLanguageGroup: React.FunctionComponent = () => {
104104
getItemProps: (options: GetItemPropsOptions<any>) => {},
105105
getMenuProps: (options: GetMenuPropsOptions) => {}
106106
) => {
107-
languagesToDisplay = getLanguagesMatchingSearchTerm(searchTerm).filter(
108-
(lang) => preferredLangCodes.indexOf(lang.isoCode) < 0
109-
);
107+
const hasSearchTerm = !!searchTerm?.trim();
108+
const matchingLanguages = getLanguagesMatchingSearchTerm(searchTerm);
109+
// Historically we excluded favorites from the main list to avoid showing duplicates.
110+
// However, that makes it look like search is broken when the language you're typing
111+
// is already in the "Favorite languages" section (which is also hidden while typing).
112+
// In search mode, include favorites in results. BL-15822
113+
languagesToDisplay = hasSearchTerm
114+
? matchingLanguages
115+
: matchingLanguages.filter(
116+
(lang) => preferredLangCodes.indexOf(lang.isoCode) < 0
117+
);
110118
const prefColor = commonUI.colors.bloomRed;
111119
// if (!showAll && languagesToDisplay.length > 10) {
112120
// languagesToDisplay.splice(10);

0 commit comments

Comments
 (0)