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-group): value handling #33362

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "fix radio/group value handling",
"packageName": "@fluentui/web-components",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export function radioGroupTemplate<T extends RadioGroup>(): ElementViewTemplate<
@focusout="${(x, c) => x.focusoutHandler(c.event as FocusEvent)}"
@keydown="${(x, c) => x.keydownHandler(c.event as KeyboardEvent)}"
>
<slot @slotchange="${(x, c) => x.slotchangeHandler(c.event as Event)}"></slot>
<slot @slotchange="${(x, c) => x.slotchangeHandler()}"></slot>
</template>
`;
}
Expand Down
8 changes: 4 additions & 4 deletions packages/web-components/src/radio-group/radio-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -564,9 +564,9 @@ export class RadioGroup extends FASTElement {
* @param e - the slot change event
* @internal
*/
public slotchangeHandler(e: Event): void {
Updates.enqueue(() => {
this.radios = [...this.querySelectorAll('*')].filter(x => x instanceof Radio) as Radio[];
});
public slotchangeHandler(): void {
this.radios = [...this.querySelectorAll('*')].filter(x => x instanceof Radio) as Radio[];
/** this looks silly but is needed to trigger the setter updates (form value + checkedIndex) */
this.value = this.value; // eslint-disable-line no-self-assign
}
}
1 change: 0 additions & 1 deletion packages/web-components/src/radio/radio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export class Radio extends BaseCheckbox {
protected disabledChanged(prev: boolean | undefined, next: boolean | undefined): void {
super.disabledChanged(prev, next);
if (next) {
this.checked = false;
this.tabIndex = -1;
}

Expand Down