diff --git a/CHANGELOG.md b/CHANGELOG.md index 5832f3dc..1f16c5c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ * Fix regression of `UnhighlightItem` event not firing [#1173](https://github.com/Choices-js/Choices/issues/1173) * Fix `clearChoices()` would remove items, and clear the search flag. * Fixes for opt-group handling/rendering +* Fix `removeChoice()` did not properly remove a choice which was part of a group ### Chore * Add e2e tests for "no choices" behavior to match v10 diff --git a/src/scripts/reducers/choices.ts b/src/scripts/reducers/choices.ts index 20f2463e..961575d8 100644 --- a/src/scripts/reducers/choices.ts +++ b/src/scripts/reducers/choices.ts @@ -22,6 +22,9 @@ export default function choices(s: StateType, action: ActionTypes, context?: Opt case ActionType.REMOVE_CHOICE: { action.choice.choiceEl = undefined; + if (action.choice.group) { + action.choice.group.choices = action.choice.group.choices.filter((obj) => obj.id !== action.choice.id); + } state = state.filter((obj) => obj.id !== action.choice.id); break; }