diff --git a/CHANGELOG.md b/CHANGELOG.md index bb1a833b..5832f3dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ * Fix regression "no choices to choose from"/"no results found" notice did not reliably trigger. [#1185](https://github.com/Choices-js/Choices/issues/1185) [#1191](https://github.com/Choices-js/Choices/issues/1191) * 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 ### Chore * Add e2e tests for "no choices" behavior to match v10 diff --git a/src/scripts/templates.ts b/src/scripts/templates.ts index e5d82b40..4a672a59 100644 --- a/src/scripts/templates.ts +++ b/src/scripts/templates.ts @@ -268,7 +268,6 @@ const templates: TemplatesInterface = { label = escapeForTemplate(allowHTML, label); label += ` (${groupName})`; label = { trusted: label }; - div.dataset.groupId = `${choice.groupId}`; } let describedBy: HTMLElement = div; @@ -308,6 +307,9 @@ const templates: TemplatesInterface = { if (selectText) { div.dataset.selectText = selectText; } + if (choice.groupId) { + div.dataset.groupId = `${choice.groupId}`; + } assignCustomProperties(div, choice, false);