Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

fix: search should end if selection is empty

ammarahm-edce84dcbd022e
diff --git a/apps/mobile/src/provider/stores.ts b/apps/mobile/src/provider/stores.ts
index 0bc16a253..061ff6b61 100644
--- a/apps/mobile/src/provider/stores.ts
+++ b/apps/mobile/src/provider/stores.ts
@@ -25,6 +25,7 @@ import {groupArray} from 'notes-core/utils/grouping';
import {EditorWebView, post} from '../views/Editor/Functions';
import tiny from '../views/Editor/tiny/tiny';
import {eSubscribeEvent, eUnSubscribeEvent} from '../services/EventManager';
+import {endSearch} from '../views/Editor/tiny/toolbar/commands';
export const useNoteStore = create<NoteStore>((set, get) => ({
notes: [],
@@ -289,13 +290,19 @@ export const useEditorStore = create<EditorStore>((set, get) => ({
searchReplace: false,
searchSelection: null,
setSearchReplace: searchReplace => {
- set({searchReplace});
if (!searchReplace) {
- set({searchSelection: null});
+ set({searchSelection: null, searchReplace: false});
return;
}
let func = (value: string) => {
- set({searchSelection: value});
+ console.log("setSearchReplace:", value, value.length);
+ if ((!value || value.trim() === '') && get().searchReplace) {
+ endSearch();
+ return;
+ }
+
+ set({searchSelection: value, searchReplace: true});
+
eUnSubscribeEvent('selectionvalue', func);
};
eSubscribeEvent('selectionvalue', func);