Skip to content

Commit

Permalink
Merge pull request #1194 from Choices-js/fix-unhighlightItem-event
Browse files Browse the repository at this point in the history
Fix regression of UnhighlightItem event not firing (#1173)
  • Loading branch information
Xon authored Sep 4, 2024
2 parents bef1adf + 6362e49 commit daa506c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/choices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions test/scripts/choices.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit daa506c

Please sign in to comment.