Skip to content

Commit

Permalink
fix(radio): prevent triggering click action on radio keyboard navigation
Browse files Browse the repository at this point in the history
As click events propagates, triggering a click action on radio-button
creates potential side-effect (for instance, this will activate ripple
effect of parent container like md-list-item).
  • Loading branch information
christophe-g committed Jul 9, 2023
1 parent 1893e08 commit c8b589b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion radio/lib/single-selection-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,13 @@ export class SingleSelectionController implements ReactiveController {
}

// The next sibling should be checked, focused and dispatch a change event
nextSibling.checked = true;
nextSibling.removeAttribute('tabindex');
nextSibling.click();
nextSibling.focus();
// Fire a change event since the change is triggered by a user action.
// This matches native <input type="radio"> behavior.
nextSibling.dispatchEvent(new Event('change', {bubbles: true}));

break;
}
};
Expand Down

0 comments on commit c8b589b

Please sign in to comment.