From adbb9a6b95885bcbc06f59a4480c552cb3543773 Mon Sep 17 00:00:00 2001 From: Aslam H Date: Tue, 22 Oct 2024 21:29:08 +0700 Subject: [PATCH] chore: reset palette state --- web/app/components/command-palette/command-palette.tsx | 7 +++++++ web/app/routes/_layout/_pages/search/index.tsx | 6 +----- web/shared/editor/hooks/use-la-editor.ts | 3 ++- web/shared/hooks/use-throttle-callback.ts | 1 + 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/web/app/components/command-palette/command-palette.tsx b/web/app/components/command-palette/command-palette.tsx index 4dce29dc..654d3947 100644 --- a/web/app/components/command-palette/command-palette.tsx +++ b/web/app/components/command-palette/command-palette.tsx @@ -149,6 +149,13 @@ export function RealCommandPalette() { [bounce, setOpen], ) + React.useEffect(() => { + if (!open) { + setInputValue("") + setActivePage("home") + } + }, [open, setActivePage, setInputValue]) + const filteredCommands = React.useMemo( () => getFilteredCommands(), [getFilteredCommands], diff --git a/web/app/routes/_layout/_pages/search/index.tsx b/web/app/routes/_layout/_pages/search/index.tsx index eb2c2d7b..c0a888fc 100644 --- a/web/app/routes/_layout/_pages/search/index.tsx +++ b/web/app/routes/_layout/_pages/search/index.tsx @@ -1,9 +1,5 @@ import * as React from "react" -import { - useAccount, - useAccountOrGuest, - useCoState, -} from "@/lib/providers/jazz-provider" +import { useAccountOrGuest, useCoState } from "@/lib/providers/jazz-provider" import { LaIcon } from "@/components/custom/la-icon" import { Topic, PersonalLink, PersonalPage } from "@/lib/schema" import { PublicGlobalGroup } from "@/lib/schema/master/public-group" diff --git a/web/shared/editor/hooks/use-la-editor.ts b/web/shared/editor/hooks/use-la-editor.ts index ebdc1c0e..3da71786 100644 --- a/web/shared/editor/hooks/use-la-editor.ts +++ b/web/shared/editor/hooks/use-la-editor.ts @@ -239,12 +239,13 @@ export const useLaEditor = ({ ...props, }), [ + me, placeholder, mergedEditorProps, + props, throttledSetValue, handleCreate, handleBlur, - props, ], ) diff --git a/web/shared/hooks/use-throttle-callback.ts b/web/shared/hooks/use-throttle-callback.ts index 6d7fc7ad..da1fe977 100644 --- a/web/shared/hooks/use-throttle-callback.ts +++ b/web/shared/hooks/use-throttle-callback.ts @@ -48,6 +48,7 @@ export function useThrottleCallback( ) } }, + // eslint-disable-next-line react-hooks/exhaustive-deps [delay, ...deps], ) as T }