Skip to content

Commit

Permalink
fix: delegate details theme attribute in Lit version (#8267)
Browse files Browse the repository at this point in the history
  • Loading branch information
web-padawan authored Dec 3, 2024
1 parent cec56a3 commit 9ff7624
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
25 changes: 20 additions & 5 deletions packages/details/src/vaadin-details-base-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,8 @@ export const DetailsBaseMixin = (superClass) =>
return ['__updateAriaControls(focusElement, _contentElements)', '__updateAriaExpanded(focusElement, opened)'];
}

static get delegateAttrs() {
return ['theme'];
}

static get delegateProps() {
return ['disabled', 'opened'];
return ['disabled', 'opened', '_theme'];
}

constructor() {
Expand Down Expand Up @@ -67,6 +63,25 @@ export const DetailsBaseMixin = (superClass) =>
this.addController(this._tooltipController);
}

/**
* Override method from `DelegateStateMixin` to set delegate `theme`
* using attribute instead of property (needed for the Lit version).
* @protected
* @override
*/
_delegateProperty(name, value) {
if (!this.stateTarget) {
return;
}

if (name === '_theme') {
this._delegateAttribute('theme', value);
return;
}

super._delegateProperty(name, value);
}

/**
* Override method inherited from `DisabledMixin`
* to not set `aria-disabled` on the host element.
Expand Down
10 changes: 10 additions & 0 deletions packages/details/test/details.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,16 @@ describe('vaadin-details', () => {
await nextUpdate(details);
expect(summary.hasAttribute('disabled')).to.be.false;
});

it(`should propagate theme attribute to ${type} summary`, async () => {
details.setAttribute('theme', 'filled');
await nextUpdate(details);
expect(summary.getAttribute('theme')).to.equal('filled');

details.removeAttribute('theme');
await nextUpdate(details);
expect(summary.hasAttribute('theme')).to.be.false;
});
});
});

Expand Down

0 comments on commit 9ff7624

Please # to comment.