Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 5 additions & 0 deletions .changeset/real-suns-float.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': patch
---

Fixes pagination not resetting to the first page when searching the Custom Sounds and Custom Emojis admin tables. Searching from a later page previously kept the stale offset, so the filtered request ran with an out-of-range offset and returned an empty result set.
10 changes: 8 additions & 2 deletions apps/meteor/client/views/admin/customEmoji/CustomEmoji.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,13 @@ const CustomEmoji = ({ onClick, reload }: CustomEmojiProps) => {

return (
<>
<FilterByText value={text} onChange={(event) => setText(event.target.value)} />
<FilterByText
value={text}
onChange={(event) => {
setText(event.target.value);
onSetCurrent(0);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: The new search-reset behavior is not covered by a regression test: the current specs never search from a later page or assert that the resulting custom emoji/sound request uses offset 0. Adding an interaction test that navigates to page 2, types a search term, and verifies the endpoint query would make CORE-2096 resistant to regressions.

(Based on your team's feedback about meaningful behavior and edge-case tests.) .

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/meteor/client/views/admin/customEmoji/CustomEmoji.tsx, line 75:

<comment>The new search-reset behavior is not covered by a regression test: the current specs never search from a later page or assert that the resulting custom emoji/sound request uses offset 0. Adding an interaction test that navigates to page 2, types a search term, and verifies the endpoint query would make CORE-2096 resistant to regressions.

(Based on your team's feedback about meaningful behavior and edge-case tests.) .</comment>

<file context>
@@ -68,7 +68,13 @@ const CustomEmoji = ({ onClick, reload }: CustomEmojiProps) => {
+				value={text}
+				onChange={(event) => {
+					setText(event.target.value);
+					onSetCurrent(0);
+				}}
+			/>
</file context>

}}
/>
{isLoading && (
<GenericTable>
<GenericTableHeader>{headers}</GenericTableHeader>
Expand Down Expand Up @@ -114,7 +120,7 @@ const CustomEmoji = ({ onClick, reload }: CustomEmojiProps) => {
/>
</>
)}
{isSuccess && data && data.emojis.length === 0 && <GenericNoResults />}
{isSuccess && data?.emojis.length === 0 && <GenericNoResults />}
{isError && (
<States>
<StatesIcon name='warning' variation='danger' />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ const CustomSoundsTable = ({ reload, onClick }: CustomSoundsTableProps) => {
const t = useTranslation();
const { sortBy, sortDirection, setSort } = useSort<'name'>('name');
const { current, itemsPerPage, setItemsPerPage: onSetItemsPerPage, setCurrent: onSetCurrent, ...paginationProps } = usePagination();

const [text, setText] = useState('');

const query = useDebouncedValue(
Expand Down Expand Up @@ -65,7 +64,13 @@ const CustomSoundsTable = ({ reload, onClick }: CustomSoundsTableProps) => {

return (
<>
<FilterByText value={text} onChange={(event) => setText(event.target.value)} />
<FilterByText
value={text}
onChange={(event) => {
setText(event.target.value);
onSetCurrent(0);
}}
/>
{isLoading && (
<GenericTable>
<GenericTableHeader>{headers}</GenericTableHeader>
Expand Down
Loading