Skip to content

Build your personal knowledge base with Trilium Notes

fix(spreadsheet): search triggers regardless of note context

Elian Doran96e0503265aa
diff --git a/apps/client/src/widgets/type_widgets/spreadsheet/Spreadsheet.tsx b/apps/client/src/widgets/type_widgets/spreadsheet/Spreadsheet.tsx
index 17ba1c1a83..6f19183daa 100644
--- a/apps/client/src/widgets/type_widgets/spreadsheet/Spreadsheet.tsx
+++ b/apps/client/src/widgets/type_widgets/spreadsheet/Spreadsheet.tsx
@@ -29,6 +29,7 @@ import { createUniver, FUniver, LocaleType, mergeLocales } from '@univerjs/prese
import { IDialogService, ISidebarService } from '@univerjs/ui';
import { MutableRef, useEffect, useRef } from "preact/hooks";
+import type NoteContext from "../../../components/note_context";
import { t } from "../../../services/i18n";
import { useColorScheme, useEffectiveReadOnly, useTriliumEvent, useTriliumEvents } from "../../react/hooks";
import { TypeWidgetProps } from "../type_widget";
@@ -72,7 +73,7 @@ function SpreadsheetEditor({ note, noteContext, readOnly }: TypeWidgetProps & {
useInitializeSpreadsheet(containerRef, apiRef, readOnly);
useDarkMode(apiRef);
usePersistence(note, noteContext, apiRef, containerRef);
- useSearchIntegration(apiRef);
+ useSearchIntegration(apiRef, noteContext);
useDismissDialogsOnNoteSwitch(apiRef);
useFixRadixPortals();
@@ -195,8 +196,10 @@ function useDarkMode(apiRef: MutableRef<FUniver | undefined>) {
}, [ colorScheme, apiRef ]);
}
-function useSearchIntegration(apiRef: MutableRef<FUniver | undefined>) {
+function useSearchIntegration(apiRef: MutableRef<FUniver | undefined>, noteContext: NoteContext | undefined) {
useTriliumEvent("findInText", () => {
+ if (!noteContext?.isActive()) return;
+
const univerAPI = apiRef.current;
if (!univerAPI) return;