Skip to content

Commit

Permalink
fix: 重置搜索&标签页切换时,分页需重置为第一页
Browse files Browse the repository at this point in the history
  • Loading branch information
Barrior committed Jul 10, 2024
1 parent b1df0e0 commit 01d4869
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/search-table-react/src/hooks/useSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ export default function useSearch({
const handleSearchReset = useMemoizedFn(async (value: IObjectAny) => {
searchValueRef.current = { ...value }

// 除非外部事件
// 外部事件
await searchProps.onReset?.(value)

// 发送请求,重置时,分页重置为第一页
await runRequest({ page: 1 })
await runRequest({ current: 1 })
})

// 提交事件
Expand Down
10 changes: 8 additions & 2 deletions packages/search-table-react/src/hooks/useTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,14 @@ export default function useTitle({

// 等事件 setState 值更新完毕后再发起请求
setTimeout(
// 请求完毕更新 isTabChanging 值
() => runRequest().finally(() => (globalStateRef.current.isTabChanging = false)),
/**
* 1、Tab 切换分页重置到第一页
* 2、请求完毕更新 isTabChanging 值
*/
() =>
runRequest({ current: 1 }).finally(
() => (globalStateRef.current.isTabChanging = false)
),
0
)
})
Expand Down

0 comments on commit 01d4869

Please sign in to comment.