Skip to content
Snippets Groups Projects
Commit a4789db9 authored by Phil Hughes's avatar Phil Hughes
Browse files

Fixed bug replacing full input value

parent ab1b8d50
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -89,9 +89,15 @@
static getInputSelectionPosition(input) {
const inputValue = input.value;
const selectionStart = input.selectionStart;
const left = inputValue.slice(0, selectionStart + 1).search(/\S+$/);
let left = inputValue.slice(0, selectionStart + 1).search(/\S+$/);
const right = inputValue.slice(selectionStart).search(/\s/);
 
if (selectionStart === 0) {
left = 0;
} else if (selectionStart === inputValue.length && left < 0) {
left = inputValue.length;
}
return {
left,
right,
Loading
Loading
Loading
Loading
@@ -62,16 +62,13 @@
 
// Get the string to replace
const selectionStart = input.selectionStart;
let { left, right } = gl.DropdownUtils.getInputSelectionPosition(input);
const { left } = gl.DropdownUtils.getInputSelectionPosition(input);
let { right } = gl.DropdownUtils.getInputSelectionPosition(input);
 
if (right < 0) {
right = inputValue.length;
}
 
if (left < 0) {
left += 1;
}
input.value = `${inputValue.substr(0, left)}${word}${inputValue.substr(right + selectionStart)}`;
gl.FilteredSearchDropdownManager.updateInputCaretPosition(selectionStart, input);
}
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment