fix: keep search term on the url (DataTableToolbar.SearchBar) (#20521)

* fix: keep search term on the url (DataTableToolbar.SearchBar)

* update comment

* Update packages/features/data-table/components/DataTableToolbar.tsx

Co-authored-by: sean-brydon <[email protected]>

---------

Co-authored-by: sean-brydon <[email protected]>
This commit is contained in:
Eunjae Leeandsean-brydon authored and GitHub committed 2025-04-03 12:59:36 +02:00
1 parent f353fdf252
commit 1e7453edcd
7 files changed
+67 -80

No files matched your search

@@ -68,12 +68,11 @@ function UserListTableContent({ oAuthClientId }: PlatformManagedUsersTableProps)
const { t } = useLocale();
const [state, dispatch] = useReducer(reducer, initialState);
const [debouncedSearchTerm, setDebouncedSearchTerm] = useState("");
const [rowSelection, setRowSelection] = useState({});
const columnFilters = useColumnFilters();
const { pageIndex, pageSize } = useDataTable();
const { pageIndex, pageSize, searchTerm } = useDataTable();
const limit = pageSize;
const offset = pageIndex * pageSize;
@@ -81,7 +80,7 @@ function UserListTableContent({ oAuthClientId }: PlatformManagedUsersTableProps)
{
limit,
offset,
searchTerm: debouncedSearchTerm,
searchTerm,
filters: columnFilters,
oAuthClientId,
},
@@ -289,11 +288,7 @@ function UserListTableContent({ oAuthClientId }: PlatformManagedUsersTableProps)
paginationMode="standard"
ToolbarLeft={
<>
<DataTableToolbar.SearchBar
table={table}
onSearch={(value) => setDebouncedSearchTerm(value)}
className="sm:max-w-64 max-w-full"
/>
<DataTableToolbar.SearchBar className="sm:max-w-64 max-w-full" />
<DataTableFilters.ColumnVisibilityButton table={table} />
<DataTableFilters.FilterBar table={table} />
</>
@@ -134,19 +134,18 @@ function UserListTableContent() {
});
const [state, dispatch] = useReducer(reducer, initialState);
const [debouncedSearchTerm, setDebouncedSearchTerm] = useState("");
const [isDownloading, setIsDownloading] = useState(false);
const [rowSelection, setRowSelection] = useState({});
const columnFilters = useColumnFilters();
const { limit, offset, ctaContainerRef } = useDataTable();
const { limit, offset, searchTerm, ctaContainerRef } = useDataTable();
const { data, isPending } = trpc.viewer.organizations.listMembers.useQuery(
{
limit,
offset,
searchTerm: debouncedSearchTerm,
searchTerm,
expand: ["attributes"],
filters: columnFilters,
},
@@ -483,7 +482,7 @@ function UserListTableContent() {
const result = await utils.viewer.organizations.listMembers.fetch({
limit,
offset,
searchTerm: debouncedSearchTerm,
searchTerm,
expand: ["attributes"],
filters: columnFilters,
});
@@ -531,7 +530,7 @@ function UserListTableContent() {
paginationMode="standard"
ToolbarLeft={
<>
<DataTableToolbar.SearchBar table={table} onSearch={(value) => setDebouncedSearchTerm(value)} />
<DataTableToolbar.SearchBar />
<DataTableFilters.ColumnVisibilityButton table={table} />
<DataTableFilters.FilterBar table={table} />
</>