From c135578626c9f7e948267600b683488bfb3adcb3 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 8 Mar 2026 13:05:47 +0200 Subject: [PATCH] fix(spreadsheet): not focusing on tab switch --- apps/client/src/widgets/type_widgets/Spreadsheet.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/apps/client/src/widgets/type_widgets/Spreadsheet.tsx b/apps/client/src/widgets/type_widgets/Spreadsheet.tsx index 8f7d9ebf56..a4f7389ebb 100644 --- a/apps/client/src/widgets/type_widgets/Spreadsheet.tsx +++ b/apps/client/src/widgets/type_widgets/Spreadsheet.tsx @@ -8,7 +8,7 @@ import { MutableRef, useEffect, useRef } from "preact/hooks"; import NoteContext from "../../components/note_context"; import FNote from "../../entities/fnote"; -import { useColorScheme, useEditorSpacedUpdate } from "../react/hooks"; +import { useColorScheme, useEditorSpacedUpdate, useTriliumEvent } from "../react/hooks"; import { TypeWidgetProps } from "./type_widget"; interface PersistedData { @@ -24,6 +24,14 @@ export default function Spreadsheet({ note, noteContext }: TypeWidgetProps) { useDarkMode(apiRef); usePersistence(note, noteContext, apiRef); + // Focus the spreadsheet when the note is focused. + useTriliumEvent("focusOnDetail", () => { + const focusable = containerRef.current?.querySelector('[data-u-comp="editor"]'); + if (focusable instanceof HTMLElement) { + focusable.focus(); + } + }); + return
; }