diff --git a/packages/frontend/src/features/shared/components/Inputs/SearchInput.tsx b/packages/frontend/src/features/shared/components/Inputs/SearchInput.tsx index 40831b04e..5a6088f38 100644 --- a/packages/frontend/src/features/shared/components/Inputs/SearchInput.tsx +++ b/packages/frontend/src/features/shared/components/Inputs/SearchInput.tsx @@ -1,5 +1,6 @@ import { useNavigate } from 'react-router-dom' import { useState, KeyboardEvent } from 'react' +import { PATHS } from '@/constants/paths' import { ReactComponent as SearchIcon } from '@/assets/svg/search.svg' export default function SearchInput() { @@ -8,12 +9,14 @@ export default function SearchInput() { const handleSearch = (e: KeyboardEvent) => { if (e.key === 'Enter') { - navigate(`?q=${encodeURIComponent(query.trim())}`) + e.preventDefault() + e.stopPropagation() + navigate(`${PATHS.HOME}?q=${encodeURIComponent(query.trim())}`) } } const onClick = () => { - navigate(`?q=${encodeURIComponent(query.trim())}`) + navigate(`${PATHS.HOME}?q=${encodeURIComponent(query.trim())}`) } return ( diff --git a/packages/frontend/src/features/shared/components/RichTextEditor/plugins/ClearAllPlugin.tsx b/packages/frontend/src/features/shared/components/RichTextEditor/plugins/ClearAllPlugin.tsx index 8924829f9..0bed9f5c6 100644 --- a/packages/frontend/src/features/shared/components/RichTextEditor/plugins/ClearAllPlugin.tsx +++ b/packages/frontend/src/features/shared/components/RichTextEditor/plugins/ClearAllPlugin.tsx @@ -1,4 +1,4 @@ -import { CLEAR_EDITOR_COMMAND } from 'lexical' +import { $getRoot, CLEAR_EDITOR_COMMAND } from 'lexical' import { useEffect } from 'react' import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext' import { useIsFirstRender } from '@uidotdev/usehooks' @@ -14,9 +14,16 @@ export default function ClearAllPlugin({ const [editor] = useLexicalComposerContext() useEffect(() => { if (!value && !isFirstRender) { - editor.dispatchCommand(CLEAR_EDITOR_COMMAND, undefined) - editor.focus() - onClear?.() + editor.getEditorState().read(() => { + const root = $getRoot() + const isContentEmpty = root.getTextContent() === '' + + if (isContentEmpty) return + + editor.dispatchCommand(CLEAR_EDITOR_COMMAND, undefined) + editor.focus() + onClear?.() + }) } }, [value, isFirstRender, editor, onClear]) return null