Commit 26d8c3ae by Apple\Apple

🔄 fix(tables): ensure search buttons show loading state consistently across all tables

Fix inconsistent loading state behavior where search buttons in ChannelsTable,
RedemptionsTable, and UsersTable didn't display loading animation when tables
were loading data, unlike LogsTable which handled this correctly.

Changes:
- Fix ChannelsTable searchChannels function to properly manage loading state
  - Move setSearching(true) to function start and use try-finally pattern
  - Ensure loading state is set for both search and load operations
- Update search button loading prop in ChannelsTable: loading={searching} → loading={loading || searching}
- Update search button loading prop in RedemptionsTable: loading={searching} → loading={loading || searching}
- Update search button loading prop in UsersTable: loading={searching} → loading={loading || searching}

This ensures search buttons show loading state consistently when:
- Table is loading data (initial load, pagination, operations)
- Search operation is in progress

All table components now provide unified UX behavior matching LogsTable,
preventing duplicate clicks and clearly indicating system state to users.
parent 1de4af1c
...@@ -844,12 +844,14 @@ const ChannelsTable = () => { ...@@ -844,12 +844,14 @@ const ChannelsTable = () => {
const searchChannels = async (enableTagMode) => { const searchChannels = async (enableTagMode) => {
const { searchKeyword, searchGroup, searchModel } = getFormValues(); const { searchKeyword, searchGroup, searchModel } = getFormValues();
setSearching(true);
try {
if (searchKeyword === '' && searchGroup === '' && searchModel === '') { if (searchKeyword === '' && searchGroup === '' && searchModel === '') {
await loadChannels(activePage - 1, pageSize, idSort, enableTagMode); await loadChannels(activePage - 1, pageSize, idSort, enableTagMode);
// setActivePage(1); // setActivePage(1);
return; return;
} }
setSearching(true);
const res = await API.get( const res = await API.get(
`/api/channel/search?keyword=${searchKeyword}&group=${searchGroup}&model=${searchModel}&id_sort=${idSort}&tag_mode=${enableTagMode}`, `/api/channel/search?keyword=${searchKeyword}&group=${searchGroup}&model=${searchModel}&id_sort=${idSort}&tag_mode=${enableTagMode}`,
); );
...@@ -860,7 +862,9 @@ const ChannelsTable = () => { ...@@ -860,7 +862,9 @@ const ChannelsTable = () => {
} else { } else {
showError(message); showError(message);
} }
} finally {
setSearching(false); setSearching(false);
}
}; };
const updateChannelProperty = (channelId, updateFn) => { const updateChannelProperty = (channelId, updateFn) => {
...@@ -1424,7 +1428,7 @@ const ChannelsTable = () => { ...@@ -1424,7 +1428,7 @@ const ChannelsTable = () => {
<Button <Button
type="primary" type="primary"
htmlType="submit" htmlType="submit"
loading={searching} loading={loading || searching}
className="!rounded-full w-full md:w-auto" className="!rounded-full w-full md:w-auto"
> >
{t('查询')} {t('查询')}
......
...@@ -504,7 +504,7 @@ const RedemptionsTable = () => { ...@@ -504,7 +504,7 @@ const RedemptionsTable = () => {
<Button <Button
type="primary" type="primary"
htmlType="submit" htmlType="submit"
loading={searching} loading={loading || searching}
className="!rounded-full flex-1 md:flex-initial md:w-auto" className="!rounded-full flex-1 md:flex-initial md:w-auto"
> >
{t('查询')} {t('查询')}
......
...@@ -554,7 +554,7 @@ const UsersTable = () => { ...@@ -554,7 +554,7 @@ const UsersTable = () => {
<Button <Button
type="primary" type="primary"
htmlType="submit" htmlType="submit"
loading={searching} loading={loading || searching}
className="!rounded-full flex-1 md:flex-initial md:w-auto" className="!rounded-full flex-1 md:flex-initial md:w-auto"
> >
{t('查询')} {t('查询')}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment