fix(react/dialogs): autocomplete not displayed if list is empty

This commit is contained in:
Elian Doran 2025-08-04 19:27:47 +03:00
parent d5e42318dd
commit cb650b70cb
No known key found for this signature in database

View File

@ -23,10 +23,6 @@ function JumpToNoteDialogComponent({ mode }: JumpToNoteDialogProps) {
const [ isCommandMode, setIsCommandMode ] = useState(mode === "commands"); const [ isCommandMode, setIsCommandMode ] = useState(mode === "commands");
const [ text, setText ] = useState(isCommandMode ? "> " : ""); const [ text, setText ] = useState(isCommandMode ? "> " : "");
console.log(`Got text '${text}'`);
console.log("Rendering with mode:", mode, "isCommandMode:", isCommandMode);
useEffect(() => { useEffect(() => {
setIsCommandMode(text.startsWith(">")); setIsCommandMode(text.startsWith(">"));
}, [ text ]); }, [ text ]);
@ -44,7 +40,10 @@ function JumpToNoteDialogComponent({ mode }: JumpToNoteDialogProps) {
const $autoComplete = $(autocompleteRef.current); const $autoComplete = $(autocompleteRef.current);
switch (mode) { switch (mode) {
case "last-search": case "last-search":
break; // Fall-through if there is no text, in order to display the recent notes.
if (text) {
break;
}
case "recent-notes": case "recent-notes":
note_autocomplete.showRecentNotes($autoComplete); note_autocomplete.showRecentNotes($autoComplete);
break; break;