Skip to content

Commit

Permalink
fix: radio-button not add to group (#167)
Browse files Browse the repository at this point in the history
* fix: radio-button not add to group

Main-authored-by: Jidapa Nunkaew
Co-authored-by: Sarin Udompanish
Co-authored-by: Theeraphat-Sorasetsakul <[email protected]>
  • Loading branch information
Jidapa-Pai and Theeraphat-Sorasetsakul authored Feb 14, 2022
1 parent e5f7f1a commit fb05273
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
10 changes: 10 additions & 0 deletions packages/elements/src/radio-button/__test__/radio-button.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,16 @@ describe('radio-button/RadioButton', () => {
expect(btn1.checked).to.equal(false);
expect(btn2.checked).to.equal(true);
});
it('Should have only 1 checked radio and checked the new radio in a group when append a new checked radio ', async () => {
const group = [
await fixture('<ef-radio-button name="group" id="btn1" checked>1</ef-radio-button>')
];
group.push(await fixture('<ef-radio-button name="group" id="btn2" checked>2</ef-radio-button>'));
await updateGroup(group);

const checkedRadio = group.find(element => element.checked);
expect(checkedRadio.id).to.equal('btn2');
});
});

describe('Group navigation', () => {
Expand Down
6 changes: 3 additions & 3 deletions packages/elements/src/radio-button/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,11 @@ export class RadioButton extends ControlElement {
}

/**
* Invoked whenever the element is update
* Invoked whenever the element is updated
* @param changedProperties changed properties
* @returns {void}
*/
protected update (changedProperties: PropertyValues): void {
protected updated (changedProperties: PropertyValues): void {
if (this.isConnected && this.hasUpdated && changedProperties.has('name')) {
applyRegistry(this, changedProperties.get('name') as string);
}
Expand All @@ -152,7 +152,7 @@ export class RadioButton extends ControlElement {
this.manageGroupState();
}

super.update(changedProperties);
super.updated(changedProperties);
}

/**
Expand Down

0 comments on commit fb05273

Please sign in to comment.