From fd1ea05c786e3bd30b53849d4eb2c2fd46a7c468 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 10 Aug 2025 19:51:56 +0300 Subject: [PATCH] fix(react/dialogs): add link default text not working --- apps/client/src/widgets/dialogs/add_link.tsx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/apps/client/src/widgets/dialogs/add_link.tsx b/apps/client/src/widgets/dialogs/add_link.tsx index 162d3b4f1..78867304c 100644 --- a/apps/client/src/widgets/dialogs/add_link.tsx +++ b/apps/client/src/widgets/dialogs/add_link.tsx @@ -17,7 +17,7 @@ type LinkType = "reference-link" | "external-link" | "hyper-link"; function AddLinkDialogComponent() { const [ textTypeWidget, setTextTypeWidget ] = useState(); - const [ text, setText ] = useState(); + const initialText = useRef(); const [ linkTitle, setLinkTitle ] = useState(""); const hasSelection = textTypeWidget?.hasSelection(); const [ linkType, setLinkType ] = useState(hasSelection ? "hyper-link" : "reference-link"); @@ -26,7 +26,7 @@ function AddLinkDialogComponent() { useTriliumEvent("showAddLinkDialog", ( { textTypeWidget, text }) => { setTextTypeWidget(textTypeWidget); - setText(text); + initialText.current = text; setShown(true); }); @@ -63,10 +63,10 @@ function AddLinkDialogComponent() { function onShown() { const $autocompleteEl = refToJQuerySelector(autocompleteRef); - if (!text) { + if (!initialText.current) { note_autocomplete.showRecentNotes($autocompleteEl); } else { - note_autocomplete.setText($autocompleteEl, text); + note_autocomplete.setText($autocompleteEl, initialText.current); } // to be able to quickly remove entered text @@ -110,7 +110,6 @@ function AddLinkDialogComponent() {