fix(radio-group): change check of value to only null or undefined
This commit is contained in:
parent
3faf14ec5f
commit
fd98a5591d
2 changed files with 15 additions and 1 deletions
|
|
@ -94,7 +94,7 @@ export class LionRadioGroup extends LionFieldset {
|
||||||
|
|
||||||
__triggerCheckedValueChanged() {
|
__triggerCheckedValueChanged() {
|
||||||
const value = this.checkedValue;
|
const value = this.checkedValue;
|
||||||
if (value && value !== this.__previousCheckedValue) {
|
if (value != null && value !== this.__previousCheckedValue) {
|
||||||
this.dispatchEvent(
|
this.dispatchEvent(
|
||||||
new CustomEvent('checked-value-changed', { bubbles: true, composed: true }),
|
new CustomEvent('checked-value-changed', { bubbles: true, composed: true }),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,20 @@ describe('<lion-radio-group>', () => {
|
||||||
expect(el.checkedValue).to.deep.equal({ some: 'data' });
|
expect(el.checkedValue).to.deep.equal({ some: 'data' });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('can handle 0 and empty string as valid values ', async () => {
|
||||||
|
const el = await fixture(html`
|
||||||
|
<lion-radio-group>
|
||||||
|
<lion-radio name="data[]" .choiceValue=${0} .choiceChecked=${true}></lion-radio>
|
||||||
|
<lion-radio name="data[]" .choiceValue=${''}></lion-radio>
|
||||||
|
</lion-radio-group>
|
||||||
|
`);
|
||||||
|
await nextFrame();
|
||||||
|
|
||||||
|
expect(el.checkedValue).to.equal(0);
|
||||||
|
el.formElementsArray[1].choiceChecked = true;
|
||||||
|
expect(el.checkedValue).to.equal('');
|
||||||
|
});
|
||||||
|
|
||||||
it('still has a full modelValue ', async () => {
|
it('still has a full modelValue ', async () => {
|
||||||
const el = await fixture(html`
|
const el = await fixture(html`
|
||||||
<lion-radio-group>
|
<lion-radio-group>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue