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
; }