[MM-61946] Don't change the emoji picker search input text case (#29397)

This removes the search input text lowercasing from the
`EmojiPickerSearch` component, where it is used as the text displayed to
the user.

Instead, filter lowercasing is done in the `getFilteredEmojis` function
to make emoji search case-insensitive.

Signed-off-by: Kuruyia <github@kuruyia.net>
Этот коммит содержится в:
Alexandre Sollier
2024-12-05 19:16:56 +01:00
коммит произвёл GitHub
родитель 491e46d390
Коммит c67e5089c1
3 изменённых файлов: 15 добавлений и 2 удалений

Просмотреть файл

@@ -31,7 +31,7 @@ const EmojiPickerSearch = forwardRef<HTMLInputElement, Props>(({value, cursorCat
event.preventDefault();
// remove trailing and leading colons
const value = event.target.value.toLowerCase().replace(/^:|:$/g, '');
const value = event.target.value.replace(/^:|:$/g, '');
onChange(value);
resetCursorPosition();

Просмотреть файл

@@ -233,6 +233,19 @@ describe('getFilteredEmojis', () => {
expect(getFilteredEmojis(allEmojis as any, filter, recentEmojisString, userSkinTone)).toEqual(filteredResults);
});
test('Should be case-insensitive', () => {
const allEmojis = {
smile: smileEmoji,
thumbsup: thumbsupEmoji,
thumbsdown: thumbsdownEmoji,
};
const filter = 'DoWn';
const recentEmojisString: string[] = [];
const userSkinTone = '';
expect(getFilteredEmojis(allEmojis as any, filter, recentEmojisString, userSkinTone)).toStrictEqual([thumbsdownEmoji]);
});
});
describe('calculateCategoryRowIndex', () => {

Просмотреть файл

@@ -63,7 +63,7 @@ export function getFilteredEmojis(allEmojis: Record<string, Emoji>, filter: stri
const aliases = isSystemEmoji(emoji) ? emoji.short_names : [emoji.name];
for (let i = 0; i < aliases.length; i++) {
if (aliases[i].toLowerCase().includes(filter)) {
if (aliases[i].toLowerCase().includes(filter.toLowerCase())) {
return true;
}
}