input pill: Backspace deletes pills if caret is at start of input.

This allows deleting the last pill by the backspace key,
even if there is text input present.
This commit is contained in:
Ryan Rehman 2020-06-22 03:34:28 +05:30 committed by Tim Abbott
parent 1e0340e0a3
commit b57ebe717e
1 changed files with 2 additions and 1 deletions

View File

@ -266,7 +266,8 @@ exports.create = function (opts) {
// if the user backspaces and there is input, just do normal char
// deletion, otherwise delete the last pill in the sequence.
if (char === KEY.BACKSPACE && funcs.value(e.target).length === 0) {
if (char === KEY.BACKSPACE && (
funcs.value(e.target).length === 0 || window.getSelection().anchorOffset === 0)) {
e.preventDefault();
funcs.removeLastPill();