mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 10:26:08 +01:00 
			
		
		
		
	fix autofilling autocomplete label on focus
This commit is contained in:
		| @@ -130,12 +130,12 @@ $(document).bind('keydown', 'alt+l', function() { | ||||
|         }); | ||||
|     } | ||||
|  | ||||
|     function setDefaultLinkTitle() { | ||||
|         const val = $("#noteAutocomplete").val(); | ||||
|         const noteId = getNodeIdFromLabel(val); | ||||
|  | ||||
|         if (noteId) { | ||||
|     function setDefaultLinkTitle(noteId) { | ||||
|         const note = getNodeByKey(noteId); | ||||
|         if (!note) { | ||||
|             return; | ||||
|         } | ||||
|  | ||||
|         let noteTitle = note.title; | ||||
|  | ||||
|         if (noteTitle.endsWith(" (clone)")) { | ||||
| @@ -144,13 +144,25 @@ $(document).bind('keydown', 'alt+l', function() { | ||||
|  | ||||
|         $("#linkTitle").val(noteTitle); | ||||
|     } | ||||
|     } | ||||
|  | ||||
|     $("#noteAutocomplete").autocomplete({ | ||||
|         source: autocompleteItems, | ||||
|         minLength: 0, | ||||
|         change: setDefaultLinkTitle, | ||||
|         focus: setDefaultLinkTitle | ||||
|         change: function () { | ||||
|             const val = $("#noteAutocomplete").val(); | ||||
|             const noteId = getNodeIdFromLabel(val); | ||||
|  | ||||
|             if (noteId) { | ||||
|                 setDefaultLinkTitle(noteId); | ||||
|             } | ||||
|         }, | ||||
|         // this is called when user goes through autocomplete list with keyboard | ||||
|         // at this point the item isn't selected yet so we use supplied ui.item to see where the cursor is | ||||
|         focus: function (event, ui) { | ||||
|             const noteId = getNodeIdFromLabel(ui.item.value); | ||||
|  | ||||
|             setDefaultLinkTitle(noteId); | ||||
|         } | ||||
|     }); | ||||
| }); | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user