search pills: Update multiple pills creation event behaviour.

If typeahead is used, this adds comma separated search queries
so that multiple search pills don't get combined as one and the
search behaviour remains same as search_pills_enabled = False case.

If typeahead is not used, this prevent the typing of a single comma
after the pill gets created.
This commit is contained in:
Ryan Rehman
2020-06-01 06:12:46 +05:30
committed by Tim Abbott
parent 9faf238e8e
commit b0d632577f
4 changed files with 12 additions and 12 deletions

View File

@@ -283,19 +283,17 @@ exports.create = function (opts) {
}
}
// users should not be able to type a comma if the last field doesn't
// validate.
// Typing of the comma is prevented if the last field doesn't validate,
// as well as when the new pill is created.
if (char === KEY.COMMA) {
// if the pill is successful, it will create the pill and clear
// the input.
if (funcs.appendPill(store.$input.text().trim()) !== false) {
funcs.clear(store.$input[0]);
// otherwise it will prevent the typing of the comma because they
// cannot add another pill until this input is valid.
} else {
e.preventDefault();
return;
}
e.preventDefault();
return;
}
});