diff --git a/.changeset/real-suns-float.md b/.changeset/real-suns-float.md new file mode 100644 index 0000000000000..bb1b2f07775b4 --- /dev/null +++ b/.changeset/real-suns-float.md @@ -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. diff --git a/apps/meteor/client/views/admin/customEmoji/CustomEmoji.tsx b/apps/meteor/client/views/admin/customEmoji/CustomEmoji.tsx index b3aba8668e7ef..5701985956249 100644 --- a/apps/meteor/client/views/admin/customEmoji/CustomEmoji.tsx +++ b/apps/meteor/client/views/admin/customEmoji/CustomEmoji.tsx @@ -68,7 +68,13 @@ const CustomEmoji = ({ onClick, reload }: CustomEmojiProps) => { return ( <> - setText(event.target.value)} /> + { + setText(event.target.value); + onSetCurrent(0); + }} + /> {isLoading && ( {headers} @@ -114,7 +120,7 @@ const CustomEmoji = ({ onClick, reload }: CustomEmojiProps) => { /> )} - {isSuccess && data && data.emojis.length === 0 && } + {isSuccess && data?.emojis.length === 0 && } {isError && ( diff --git a/apps/meteor/client/views/admin/customSounds/CustomSoundsTable/CustomSoundsTable.tsx b/apps/meteor/client/views/admin/customSounds/CustomSoundsTable/CustomSoundsTable.tsx index 70f928134e763..ca097f0c06a18 100644 --- a/apps/meteor/client/views/admin/customSounds/CustomSoundsTable/CustomSoundsTable.tsx +++ b/apps/meteor/client/views/admin/customSounds/CustomSoundsTable/CustomSoundsTable.tsx @@ -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( @@ -65,7 +64,13 @@ const CustomSoundsTable = ({ reload, onClick }: CustomSoundsTableProps) => { return ( <> - setText(event.target.value)} /> + { + setText(event.target.value); + onSetCurrent(0); + }} + /> {isLoading && ( {headers}