fix(lion-accordion): make a copy when changing expanded (#2047)
This commit is contained in:
parent
857d47a933
commit
cecf5ed573
3 changed files with 14 additions and 1 deletions
5
.changeset/sixty-cycles-dance.md
Normal file
5
.changeset/sixty-cycles-dance.md
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'@lion/ui': patch
|
||||
---
|
||||
|
||||
lion-accordion now replaces expanded with a copy when it changes on click of an invoker button.
|
||||
|
|
@ -441,7 +441,7 @@ export class LionAccordion extends LitElement {
|
|||
* @private
|
||||
*/
|
||||
__toggleExpanded(value) {
|
||||
const { expanded } = this;
|
||||
const expanded = [...this.expanded];
|
||||
const index = expanded.indexOf(value);
|
||||
|
||||
if (index === -1) {
|
||||
|
|
|
|||
|
|
@ -80,6 +80,14 @@ describe('<lion-accordion>', () => {
|
|||
).to.equal('invoker 1');
|
||||
});
|
||||
|
||||
it('updates expanded with a new array when an invoker is clicked', async () => {
|
||||
const el = /** @type {LionAccordion} */ (await fixture(basicAccordion));
|
||||
const invokers = getInvokers(el);
|
||||
const oldExpanded = el.expanded;
|
||||
invokers[1].firstElementChild?.dispatchEvent(new Event('click'));
|
||||
expect(el.expanded).to.not.equal(oldExpanded);
|
||||
});
|
||||
|
||||
it('has [expanded] on current expanded invoker which serves as styling hook', async () => {
|
||||
const el = /** @type {LionAccordion} */ (await fixture(basicAccordion));
|
||||
const invokers = getInvokers(el);
|
||||
|
|
|
|||
Loading…
Reference in a new issue