[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();
|
event.preventDefault();
|
||||||
|
|
||||||
// remove trailing and leading colons
|
// remove trailing and leading colons
|
||||||
const value = event.target.value.toLowerCase().replace(/^:|:$/g, '');
|
const value = event.target.value.replace(/^:|:$/g, '');
|
||||||
onChange(value);
|
onChange(value);
|
||||||
|
|
||||||
resetCursorPosition();
|
resetCursorPosition();
|
||||||
|
|||||||
@@ -233,6 +233,19 @@ describe('getFilteredEmojis', () => {
|
|||||||
|
|
||||||
expect(getFilteredEmojis(allEmojis as any, filter, recentEmojisString, userSkinTone)).toEqual(filteredResults);
|
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', () => {
|
describe('calculateCategoryRowIndex', () => {
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ export function getFilteredEmojis(allEmojis: Record<string, Emoji>, filter: stri
|
|||||||
const aliases = isSystemEmoji(emoji) ? emoji.short_names : [emoji.name];
|
const aliases = isSystemEmoji(emoji) ? emoji.short_names : [emoji.name];
|
||||||
|
|
||||||
for (let i = 0; i < aliases.length; i++) {
|
for (let i = 0; i < aliases.length; i++) {
|
||||||
if (aliases[i].toLowerCase().includes(filter)) {
|
if (aliases[i].toLowerCase().includes(filter.toLowerCase())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user