mirror of
https://github.com/zadam/trilium.git
synced 2026-03-22 08:13:46 +01:00
fix(spreadsheet): not focusing on tab switch
This commit is contained in:
parent
9a6e20029e
commit
c135578626
@ -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" />;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user