Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: search table result loading #1534

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/Tables/TableGrid/TableGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default function TableGrid({
<SlideTransition
key={table.id}
appear
timeout={(sectionIndex + 1) * 100 + tableIndex * 50}
timeout={(sectionIndex + 1) * 50 + tableIndex * 25}
>
<Grid item xs={12} sm={6} md={4} lg={3}>
<TableCard
Expand All @@ -53,7 +53,7 @@ export default function TableGrid({
<SlideTransition
key={"grid-section-" + sectionName}
in
timeout={(sectionIndex + 1) * 100}
timeout={(sectionIndex + 1) * 50}
>
<SectionHeading sx={{ pl: 2, pr: 1.5 }}>
{sectionName}
Expand Down
4 changes: 2 additions & 2 deletions src/components/Tables/TableList/TableList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ export default function TableList({
<SlideTransition
key={"list-section-" + sectionName}
in
timeout={(sectionIndex + 1) * 100}
timeout={(sectionIndex + 1) * 50}
>
<SectionHeading sx={{ pl: 2, pr: 1 }}>
{sectionName}
</SectionHeading>
</SlideTransition>

<SlideTransition in timeout={(sectionIndex + 1) * 100}>
<SlideTransition in timeout={(sectionIndex + 1) * 50}>
<Paper>
<List disablePadding>
<TransitionGroup>{tableItems}</TransitionGroup>
Expand Down
7 changes: 5 additions & 2 deletions src/pages/TablesPage.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useAtom, useSetAtom } from "jotai";
import { find, groupBy, sortBy } from "lodash-es";
import { find, groupBy, sortBy, debounce } from "lodash-es";
import { Link } from "react-router-dom";

import {
Expand Down Expand Up @@ -64,6 +64,9 @@ export default function TablesPage() {
SEARCH_KEYS
);

// Debounce the handleQuery function with a delay of 300 milliseconds
const debouncedHandleQuery = debounce((value) => handleQuery(value), 300);

const favorites = Array.isArray(userSettings.favoriteTables)
? userSettings.favoriteTables
: [];
Expand Down Expand Up @@ -183,7 +186,7 @@ export default function TablesPage() {
<Container component="main" sx={{ px: 1, pt: 1, pb: 7 + 3 + 3 }}>
<FloatingSearch
label="Search tables"
onChange={(e) => handleQuery(e.target.value)}
onChange={(e) => debouncedHandleQuery(e.target.value)}
paperSx={{
maxWidth: (theme) => ({
md: theme.breakpoints.values.sm - 48 * 4,
Expand Down