Skip to content

Commit

Permalink
[MM-61946] Don't change the emoji picker search input text case (matt…
Browse files Browse the repository at this point in the history
…ermost#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 <[email protected]>
  • Loading branch information
Kuruyia authored Dec 5, 2024
1 parent 491e46d commit c67e508
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
13 changes: 13 additions & 0 deletions webapp/channels/src/components/emoji_picker/utils/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
2 changes: 1 addition & 1 deletion webapp/channels/src/components/emoji_picker/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down

0 comments on commit c67e508

Please sign in to comment.