fix(spreadsheet): not focusing on tab switch

This commit is contained in:
Elian Doran 2026-03-08 13:05:47 +02:00
parent 9a6e20029e
commit c135578626
No known key found for this signature in database

View File

@ -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 <div ref={containerRef} className="spreadsheet" />;
}