Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: radio-button not add to group #167

Merged
merged 7 commits into from
Feb 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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