Skip to content

Commit

Permalink
Fix regression of choices without groups where not rendered when grou…
Browse files Browse the repository at this point in the history
…ps where present
  • Loading branch information
Xon committed Sep 5, 2024
1 parent 6b77671 commit ecc21a3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/scripts/choices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -996,6 +996,13 @@ class Choices {
if (config.shouldSort) {
activeGroups.sort(config.sorter);
}
// render Choices without group first, regardless of sort, otherwise they won't be distinguishable
// from the last group
renderChoices(
activeChoices.filter((choice) => !choice.placeholder && !choice.group),
false,
undefined,
);

activeGroups.forEach((group) => {
const groupChoices = renderableChoices(group.choices);
Expand Down
3 changes: 2 additions & 1 deletion test-e2e/tests/select-multiple.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,8 @@ describe(`Choices - select multiple`, () => {
await suite.group.locator('.destroy').click({ force: true });
await suite.advanceClock();

await expect(suite.group.locator('select > option')).toHaveCount(3);
await expect(suite.group.locator('select > optgroup > option')).toHaveCount(1);
await expect(suite.group.locator('select > option')).toHaveCount(2);

await suite.group.locator('.init').click({ force: true });
await suite.advanceClock();
Expand Down
3 changes: 2 additions & 1 deletion test-e2e/tests/select-one.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,8 @@ describe(`Choices - select one`, () => {
await suite.group.locator('.destroy').click({ force: true });
await suite.advanceClock();

await expect(suite.group.locator('select > option')).toHaveCount(3);
await expect(suite.group.locator('select > optgroup > option')).toHaveCount(1);
await expect(suite.group.locator('select > option')).toHaveCount(2);

await suite.group.locator('.init').click({ force: true });
await suite.advanceClock();
Expand Down

0 comments on commit ecc21a3

Please sign in to comment.