Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Fix regression in emoji picker order mangling after clearing filter #10854

Merged
merged 4 commits into from
May 11, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/views/emojipicker/EmojiPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ class EmojiPicker extends React.Component<IProps, IState> {
emojis = cat.id === "recent" ? this.recentlyUsed : DATA_BY_CATEGORY[cat.id];
}

if (lcFilter) {
if (!!lcFilter) {
t3chguy marked this conversation as resolved.
Show resolved Hide resolved
emojis = emojis.filter((emoji) => this.emojiMatchesFilter(emoji, lcFilter));
// Copy the array to not clobber the original unfiltered sorting
emojis = [...emojis].sort((a, b) => {
Expand Down
5 changes: 5 additions & 0 deletions test/components/views/emojipicker/EmojiPicker-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,15 @@ describe("EmojiPicker", function () {
<EmojiPicker ref={ref} onChoose={(str: string) => false} onFinished={jest.fn()} />,
);

// Record the HTML before filtering
const beforeHtml = container.innerHTML;

// Apply a filter and assert that the HTML has changed
//@ts-ignore private access
ref.current!.onChangeFilter("test");
expect(beforeHtml).not.toEqual(container.innerHTML);

// Clear the filter and assert that the HTML matches what it was before filtering
//@ts-ignore private access
ref.current!.onChangeFilter("");
expect(beforeHtml).toEqual(container.innerHTML);
Expand Down