Skip to content

Commit fd98a55

Browse files
committed
fix(radio-group): change check of value to only null or undefined
1 parent 3faf14e commit fd98a55

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

packages/radio-group/src/LionRadioGroup.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export class LionRadioGroup extends LionFieldset {
9494

9595
__triggerCheckedValueChanged() {
9696
const value = this.checkedValue;
97-
if (value && value !== this.__previousCheckedValue) {
97+
if (value != null && value !== this.__previousCheckedValue) {
9898
this.dispatchEvent(
9999
new CustomEvent('checked-value-changed', { bubbles: true, composed: true }),
100100
);

packages/radio-group/test/lion-radio-group.test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,20 @@ describe('<lion-radio-group>', () => {
3636
expect(el.checkedValue).to.deep.equal({ some: 'data' });
3737
});
3838

39+
it('can handle 0 and empty string as valid values ', async () => {
40+
const el = await fixture(html`
41+
<lion-radio-group>
42+
<lion-radio name="data[]" .choiceValue=${0} .choiceChecked=${true}></lion-radio>
43+
<lion-radio name="data[]" .choiceValue=${''}></lion-radio>
44+
</lion-radio-group>
45+
`);
46+
await nextFrame();
47+
48+
expect(el.checkedValue).to.equal(0);
49+
el.formElementsArray[1].choiceChecked = true;
50+
expect(el.checkedValue).to.equal('');
51+
});
52+
3953
it('still has a full modelValue ', async () => {
4054
const el = await fixture(html`
4155
<lion-radio-group>

0 commit comments

Comments
 (0)