Skip to content

Commit

Permalink
fix: paginator not resetting after searching another keywords (close a…
Browse files Browse the repository at this point in the history
  • Loading branch information
xhofe committed Aug 10, 2023
1 parent 810ed67 commit 4447dd1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/components/Paginator.tsx
Expand Up @@ -19,6 +19,7 @@ export interface PaginatorProps {
total: number
defaultPageSize?: number
maxShowPage?: number
setResetCallback?: (callback: () => void) => void
}
export const Paginator = (props: PaginatorProps) => {
const merged = mergeProps(
Expand All @@ -34,6 +35,9 @@ export const Paginator = (props: PaginatorProps) => {
pageSize: merged.defaultPageSize,
current: merged.defaultCurrent,
})
merged.setResetCallback?.(() => {
setStore("current", merged.defaultCurrent)
})
const pages = createMemo(() => {
return Math.ceil(merged.total / store.pageSize)
})
Expand Down
4 changes: 3 additions & 1 deletion src/pages/home/folder/Search.tsx
Expand Up @@ -207,8 +207,9 @@ const Search = () => {
})
const [scope, setScope] = createSignal(0)
const scopes = ["all", "folder", "file"]

let resetPaginator: () => void
const search = async (page = 1) => {
page === 1 && resetPaginator?.()
if (loading()) return
setData({
content: [],
Expand Down Expand Up @@ -312,6 +313,7 @@ const Search = () => {
onChange={(page) => {
search(page)
}}
setResetCallback={(reset) => (resetPaginator = reset)}
/>
</VStack>
</ModalBody>
Expand Down

0 comments on commit 4447dd1

Please sign in to comment.