mirror of
https://github.com/rr-/szurubooru.git
synced 2025-07-17 08:26:24 +00:00
client/search: make autocomplete replace current word and set cursor pos
Better behavior for autocomplete in the middle of an already typed tag.
This commit is contained in:
@ -70,11 +70,18 @@ class AutoCompleteControl {
|
||||
prefix = this._sourceInputNode.value.substring(0, index + 1);
|
||||
middle = this._sourceInputNode.value.substring(index + 1);
|
||||
}
|
||||
suffix = spaceIndex < commaIndex ? suffix.replace(/^[^,]+/, "") : suffix.replace(/^\S+/, "");
|
||||
suffix = suffix.trimLeft();
|
||||
this._sourceInputNode.value =
|
||||
prefix + result.toString() + delimiter + suffix.trimLeft();
|
||||
prefix + result.toString() + delimiter + suffix;
|
||||
if (!addSpace) {
|
||||
this._sourceInputNode.value = this._sourceInputNode.value.trim();
|
||||
this._sourceInputNode.value = this._sourceInputNode.value.trimLeft();
|
||||
}
|
||||
const selection = this._sourceInputNode.value.length - suffix.length;
|
||||
if (!addSpace) {
|
||||
this._sourceInputNode.value = this._sourceInputNode.value.trimRight();
|
||||
}
|
||||
this._sourceInputNode.setSelectionRange(selection, selection);
|
||||
this._sourceInputNode.focus();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user