add a space after selecting a dropdown item

This commit is contained in:
Mike Greiling 2017-01-21 13:11:28 -06:00
parent 37382d3299
commit d07acd42b5
2 changed files with 11 additions and 2 deletions

View File

@ -39,6 +39,7 @@
}
this.dismissDropdown();
this.dispatchInputEvent();
}
}

View File

@ -61,11 +61,19 @@
const word = `${tokenName}:${tokenValue}`;
// Get the string to replace
const selectionStart = input.selectionStart;
let newCaretPosition = input.selectionStart;
const { left, right } = gl.DropdownUtils.getInputSelectionPosition(input);
input.value = `${inputValue.substr(0, left)}${word}${inputValue.substr(right)}`;
gl.FilteredSearchDropdownManager.updateInputCaretPosition(selectionStart, input);
// If we have added a tokenValue at the end of the input,
// add a space and set selection to the end
if (right >= inputValue.length && tokenValue !== '') {
input.value += ' ';
newCaretPosition = input.value.length;
}
gl.FilteredSearchDropdownManager.updateInputCaretPosition(newCaretPosition, input);
}
static updateInputCaretPosition(selectionStart, input) {