mirror of
https://github.com/zadam/trilium.git
synced 2025-11-30 12:34:24 +01:00
chore(react/empty): obtain ntxId via React props instead of DOM query
This commit is contained in:
parent
4d1a91baa6
commit
9ae1a55896
@ -10,16 +10,16 @@ import FNote from "../../entities/fnote";
|
|||||||
import search from "../../services/search";
|
import search from "../../services/search";
|
||||||
import { TypeWidgetProps } from "./type_widget";
|
import { TypeWidgetProps } from "./type_widget";
|
||||||
|
|
||||||
export default function Empty({ }: TypeWidgetProps) {
|
export default function Empty({ ntxId }: TypeWidgetProps) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<WorkspaceSwitcher />
|
<WorkspaceSwitcher />
|
||||||
<NoteSearch />
|
<NoteSearch ntxId={ntxId ?? null} />
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function NoteSearch() {
|
function NoteSearch({ ntxId }: { ntxId: string | null }) {
|
||||||
const resultsContainerRef = useRef<HTMLDivElement>(null);
|
const resultsContainerRef = useRef<HTMLDivElement>(null);
|
||||||
const autocompleteRef = useRef<HTMLInputElement>(null);
|
const autocompleteRef = useRef<HTMLInputElement>(null);
|
||||||
|
|
||||||
@ -45,7 +45,6 @@ function NoteSearch() {
|
|||||||
if (!suggestion?.notePath) {
|
if (!suggestion?.notePath) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const ntxId = autocompleteRef.current?.closest(".note-split")?.getAttribute("data-ntx-id") ?? null;
|
|
||||||
const activeNoteContext = appContext.tabManager.getNoteContextById(ntxId) ?? appContext.tabManager.getActiveContext();
|
const activeNoteContext = appContext.tabManager.getNoteContextById(ntxId) ?? appContext.tabManager.getActiveContext();
|
||||||
if (activeNoteContext) {
|
if (activeNoteContext) {
|
||||||
activeNoteContext.setNote(suggestion.notePath);
|
activeNoteContext.setNote(suggestion.notePath);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user