diff --git a/.changeset/silly-beds-teach.md b/.changeset/silly-beds-teach.md new file mode 100644 index 000000000..26a15fcd1 --- /dev/null +++ b/.changeset/silly-beds-teach.md @@ -0,0 +1,5 @@ +--- +'@lion/ui': patch +--- + +lion-accordion: changed selectors for invokers and content to only select slotted elements that are direct descendants. This is to prevent that slotted elements in accordion content and invokers are also selected and the amount of invokers and content is incorrect diff --git a/packages/ui/components/accordion/src/LionAccordion.js b/packages/ui/components/accordion/src/LionAccordion.js index 079f12aff..e3ecffc8c 100644 --- a/packages/ui/components/accordion/src/LionAccordion.js +++ b/packages/ui/components/accordion/src/LionAccordion.js @@ -171,12 +171,12 @@ export class LionAccordion extends LitElement { const invokers = /** @type {HTMLElement[]} */ ([ ...Array.from(existingInvokers), - ...Array.from(this.querySelectorAll('[slot="invoker"]')), + ...Array.from(this.querySelectorAll(':scope > [slot="invoker"]')), ]); const contents = /** @type {HTMLElement[]} */ ([ ...Array.from(existingContent), - ...Array.from(this.querySelectorAll('[slot="content"]')), + ...Array.from(this.querySelectorAll(':scope > [slot="content"]')), ]); if (invokers.length !== contents.length) {