mirror of
https://github.com/morpheus65535/bazarr.git
synced 2025-04-23 22:27:17 -04:00
Fixed modal with tables application crash
This commit is contained in:
parent
e17bad6ec4
commit
4f77710f46
2 changed files with 10 additions and 7 deletions
|
@ -1,5 +1,4 @@
|
|||
import { FunctionComponent } from "react";
|
||||
import { useSearchParams } from "react-router";
|
||||
import { Group, Pagination, Text } from "@mantine/core";
|
||||
import { useIsLoading } from "@/contexts";
|
||||
|
||||
|
@ -23,7 +22,6 @@ const PageControl: FunctionComponent<Props> = ({
|
|||
const end = Math.min(size * (index + 1), total);
|
||||
|
||||
const isLoading = useIsLoading();
|
||||
const [searchParams, setSearchParams] = useSearchParams();
|
||||
|
||||
return (
|
||||
<Group p={16} justify="space-between">
|
||||
|
@ -35,10 +33,6 @@ const PageControl: FunctionComponent<Props> = ({
|
|||
color={isLoading ? "gray" : "primary"}
|
||||
value={index + 1}
|
||||
onChange={(page) => {
|
||||
searchParams.set("page", page.toString());
|
||||
|
||||
setSearchParams(searchParams, { replace: true });
|
||||
|
||||
return goto(page - 1);
|
||||
}}
|
||||
hidden={count <= 1}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { useEffect } from "react";
|
||||
import { useSearchParams } from "react-router";
|
||||
import { UsePaginationQueryResult } from "@/apis/queries/hooks";
|
||||
import SimpleTable, { SimpleTableProps } from "@/components/tables/SimpleTable";
|
||||
import { LoadingProvider } from "@/contexts";
|
||||
|
@ -18,6 +19,8 @@ export default function QueryPageTable<T extends object>(props: Props<T>) {
|
|||
controls: { gotoPage },
|
||||
} = query;
|
||||
|
||||
const [searchParams, setSearchParams] = useSearchParams();
|
||||
|
||||
useEffect(() => {
|
||||
ScrollToTop();
|
||||
}, [page]);
|
||||
|
@ -30,7 +33,13 @@ export default function QueryPageTable<T extends object>(props: Props<T>) {
|
|||
index={page}
|
||||
size={pageSize}
|
||||
total={totalCount}
|
||||
goto={gotoPage}
|
||||
goto={(page) => {
|
||||
searchParams.set("page", (page + 1).toString());
|
||||
|
||||
setSearchParams(searchParams, { replace: true });
|
||||
|
||||
gotoPage(page);
|
||||
}}
|
||||
></PageControl>
|
||||
</LoadingProvider>
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue