mirror of
https://github.com/Choices-js/Choices.git
synced 2024-05-20 22:46:33 +02:00
Ensure enter key can also open single select dropdown
This commit is contained in:
parent
da68a92f31
commit
6fadbde79e
|
@ -709,9 +709,18 @@ export class Choices {
|
|||
this._handleEnter(activeItems, value);
|
||||
}
|
||||
|
||||
// Show dropdown if focus
|
||||
if(!hasActiveDropdown && this.passedElement.type === 'select-one'){
|
||||
e.preventDefault();
|
||||
this.showDropdown();
|
||||
if(this.canSearch) {
|
||||
this.input.focus();
|
||||
}
|
||||
}
|
||||
|
||||
if(hasActiveDropdown) {
|
||||
const highlighted = this.dropdown.querySelector(`.${this.config.classNames.highlightedState}`);
|
||||
|
||||
|
||||
if(highlighted) {
|
||||
const value = highlighted.getAttribute('data-value');
|
||||
const label = highlighted.innerHTML;
|
||||
|
@ -1030,6 +1039,7 @@ export class Choices {
|
|||
if(!this._focusAndHideDropdown){
|
||||
this.input.focus();
|
||||
}
|
||||
|
||||
this._focusAndHideDropdown = false;
|
||||
}
|
||||
}
|
||||
|
@ -1064,7 +1074,8 @@ export class Choices {
|
|||
*/
|
||||
_regexFilter(value) {
|
||||
if(!value) return;
|
||||
const expression = new RegExp(this.config.regexFilter, 'i');
|
||||
const regex = this.config.regexFilter;
|
||||
const expression = new RegExp(regex.source, 'i');
|
||||
return expression.test(value);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue