editor: fix search decorations not cleared on search end

This commit is contained in:
Abdullah Atta
2024-03-11 12:08:34 +05:00
parent 8fe4bddb85
commit e25016354e
2 changed files with 3 additions and 2 deletions

View File

@@ -384,6 +384,7 @@ export const SearchReplace = Extension.create<SearchOptions, SearchStorage>({
tr.getMeta("selectedIndex") ?? value.selectedIndex;
const shouldResearch =
docChanged ||
(isSearching !== value.isSearching && isSearching) ||
searchTerm !== value.searchTerm ||
matchCase !== value.matchCase ||
matchWholeWord !== value.matchWholeWord ||

View File

@@ -30,7 +30,8 @@ export function SearchReplaceFloatingMenu(props: FloatingMenuProps) {
useLayoutEffect(() => {
const { searchTerm, ...options } = useEditorSearchStore.getState();
editor.commands.search(searchTerm, options);
if (!options.isSearching) editor.commands.endSearch();
else editor.commands.search(searchTerm, options);
}, []);
return (
@@ -38,7 +39,6 @@ export function SearchReplaceFloatingMenu(props: FloatingMenuProps) {
mobile="sheet"
desktop="popup"
isOpen={isSearching}
container={document.body}
onClose={() => editor.commands.endSearch()}
position={{
target: editor.isEditable ? getToolbarElement() : getEditorContainer(),