From 93531ab013e7fbf8acc73b474b281686438b882c Mon Sep 17 00:00:00 2001 From: Xon <635541+Xon@users.noreply.github.com> Date: Thu, 5 Sep 2024 10:43:12 +0800 Subject: [PATCH] Fix group-id was not added to choices outside of search --- CHANGELOG.md | 1 + src/scripts/templates.ts | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) 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);