diff --git a/src/scripts/choices.js b/src/scripts/choices.js index f06da56..ddd0a4f 100644 --- a/src/scripts/choices.js +++ b/src/scripts/choices.js @@ -1344,12 +1344,12 @@ class Choices { if (!this._isTextElement && !hasActiveDropdown && wasAlphaNumericInput) { this.showDropdown(); - /* - We update the input value with the pressed key as - the input was not focussed at the time of key press - therefore does not have the value of the key. - */ - if (this._isSelectOneElement) { + if (!this.input.isFocussed) { + /* + We update the input value with the pressed key as + the input was not focussed at the time of key press + therefore does not have the value of the key. + */ this.input.value += keyString.toLowerCase(); } } diff --git a/src/scripts/choices.test.js b/src/scripts/choices.test.js index e7b2079..3c0b69b 100644 --- a/src/scripts/choices.test.js +++ b/src/scripts/choices.test.js @@ -2094,7 +2094,7 @@ describe('choices', () => { describe('select input', () => { describe('when the dropdown is not active', () => { - describe('when the input was alpha-numeric', () => { + describe('when the key was alpha-numeric', () => { beforeEach(() => { instance._isTextElement = false; instance.dropdown.isActive = false; @@ -2108,9 +2108,9 @@ describe('choices', () => { expect(instance.showDropdown).to.have.been.calledWith(); }); - describe('select-one input', () => { + describe('when the input is not focussed', () => { beforeEach(() => { - instance._isSelectOneElement = true; + instance.input.isFocussed = false; }); it('updates the input value with the character corresponding to the key code', () => { @@ -2122,9 +2122,9 @@ describe('choices', () => { }); }); - describe('select-multiple input', () => { + describe('when the input is focussed', () => { beforeEach(() => { - instance._isSelectOneElement = false; + instance.input.isFocussed = true; }); it('does not update the input value', () => {