Skip to content

Commit

Permalink
fix: respected disabled checked
Browse files Browse the repository at this point in the history
  • Loading branch information
jeripeierSBB committed Dec 19, 2024
1 parent a332ea6 commit 0d3e769
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ import '../radio-button-panel.js';
expect(element.value).to.be.equal(radio.value);
});

it('should ignore disabled radios', async () => {
it('should respect disabled radio in value getter', async () => {
const radio = radios[0];
radio.checked = true;
radio.disabled = true;
await waitForLitRender(element);

expect(element.value).to.be.null;
expect(element.value).to.be.equal('Value one');
});

it('should update disabled on children', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class SbbRadioButtonGroupElement extends SbbDisabledMixin(LitElement) {
if (!this._didLoad) {
return;
}
if (!val) {
if (val == null) {
this.radioButtons.forEach((r) => (r.checked = false));
return;
}
Expand All @@ -69,7 +69,7 @@ class SbbRadioButtonGroupElement extends SbbDisabledMixin(LitElement) {
}
}
public get value(): string | null {
return this.radioButtons.find((r) => r.checked && !r.disabled)?.value ?? this._fallbackValue;
return this.radioButtons.find((r) => r.checked)?.value ?? this._fallbackValue;
}
/**
* Used to preserve the `value` in case the radios are not yet 'loaded'
Expand Down

0 comments on commit 0d3e769

Please sign in to comment.