From 5448b994053f54aa3f13a1ba55824ee8b62347c9 Mon Sep 17 00:00:00 2001 From: Xon <635541+Xon@users.noreply.github.com> Date: Wed, 4 Sep 2024 19:14:27 +0800 Subject: [PATCH 1/2] Fix regression of UnhighlightItem event not firing (#1173) --- CHANGELOG.md | 1 + src/scripts/choices.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d4bec76..0f1abbb2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ * Fix choice disable state wasn't considered when showing the "no choices to choose from" notice * Fix regression "no choices to choose from" notice not triggering when no selectable choices exist for select-one. [#1185](https://github.com/Choices-js/Choices/issues/1185) * Fix regression where webpack doesn't permit importing scss/css @tagliala (#1193) +* Fix regression of UnhighlightItem event not firing [#1173](https://github.com/Choices-js/Choices/issues/1173) ### Chore * Add e2e tests for "no choices" behavior to match v10 diff --git a/src/scripts/choices.ts b/src/scripts/choices.ts index f8fd1052..d3c5fa00 100644 --- a/src/scripts/choices.ts +++ b/src/scripts/choices.ts @@ -434,7 +434,7 @@ class Choices { this._store.dispatch(highlightItem(choice, false)); if (runEvent) { - this.passedElement.triggerEvent(EventType.highlightItem, this._getChoiceForOutput(choice)); + this.passedElement.triggerEvent(EventType.unhighlightItem, this._getChoiceForOutput(choice)); } return this; From 6362e494461beab527fcb30989dbbb1f17013500 Mon Sep 17 00:00:00 2001 From: Xon <635541+Xon@users.noreply.github.com> Date: Wed, 4 Sep 2024 19:21:57 +0800 Subject: [PATCH 2/2] Fix unit tests testing the wrong thing --- test/scripts/choices.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/scripts/choices.test.ts b/test/scripts/choices.test.ts index e7f365af..de409714 100644 --- a/test/scripts/choices.test.ts +++ b/test/scripts/choices.test.ts @@ -966,7 +966,7 @@ describe('choices', () => { it('triggers event with null groupValue', () => { expect(passedElementTriggerEventStub.called).to.equal(true); - expect(passedElementTriggerEventStub.lastCall.args[0]).to.equal(EventType.highlightItem); + expect(passedElementTriggerEventStub.lastCall.args[0]).to.equal(EventType.unhighlightItem); expect(passedElementTriggerEventStub.lastCall.args[1]).to.contains({ value: item.value, label: item.label, @@ -983,7 +983,7 @@ describe('choices', () => { it('triggers event with groupValue', () => { expect(passedElementTriggerEventStub.called).to.equal(true); - expect(passedElementTriggerEventStub.lastCall.args[0]).to.equal(EventType.highlightItem); + expect(passedElementTriggerEventStub.lastCall.args[0]).to.equal(EventType.unhighlightItem); expect(passedElementTriggerEventStub.lastCall.args[1]).to.contains({ value: item.value, label: item.label,