mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-06-09 12:39:23 -03:00
fix(autocomplete): prevent blur-on-click race condition causing dropped selection (#939)
Add mousedown(e.preventDefault()) on dropdown items to prevent the textarea blur event from firing before click. Without this, the blur handler's formatAutocompleteTextOnBlur() modifies text with unmatched commas (e.g. "<lora:X:1>,search") and triggers hide() via suppressAutocompleteOnce, removing the item from the DOM before the click handler can execute. Fixes #939
This commit is contained in:
@@ -1461,6 +1461,11 @@ class AutoComplete {
|
||||
box-sizing: border-box;
|
||||
`;
|
||||
|
||||
// Prevent textarea from losing focus - same fix as createItemElement
|
||||
itemEl.addEventListener('mousedown', (e) => {
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
itemEl.addEventListener('mouseenter', () => {
|
||||
this.selectItem(index, { manual: true });
|
||||
});
|
||||
@@ -2189,6 +2194,16 @@ class AutoComplete {
|
||||
item.appendChild(nameSpan);
|
||||
}
|
||||
|
||||
// Prevent textarea from losing focus when clicking dropdown items.
|
||||
// Without this, the blur event fires before click, and the blur handler's
|
||||
// formatAutocompleteTextOnBlur() modifies the text and triggers hide()
|
||||
// via suppressAutocompleteOnce, removing this item from the DOM before
|
||||
// the click handler can execute. This specifically breaks the case where
|
||||
// the text has a comma not followed by a space (e.g. "<lora:X:1>,search").
|
||||
item.addEventListener('mousedown', (e) => {
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
// Hover and selection handlers
|
||||
item.addEventListener('mouseenter', () => {
|
||||
this.selectItem(index, { manual: true });
|
||||
|
||||
Reference in New Issue
Block a user