[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>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
491e46d390
Коммит
c67e5089c1
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user