From c8b589b734378fbdd859c18817f17f7c7a96d3e5 Mon Sep 17 00:00:00 2001 From: christophe-g Date: Sun, 9 Jul 2023 14:28:07 +0200 Subject: [PATCH] fix(radio): prevent triggering click action on radio keyboard navigation 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). --- radio/lib/single-selection-controller.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/radio/lib/single-selection-controller.ts b/radio/lib/single-selection-controller.ts index b7bfea868f..c1c935ebc4 100644 --- a/radio/lib/single-selection-controller.ts +++ b/radio/lib/single-selection-controller.ts @@ -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 behavior. + nextSibling.dispatchEvent(new Event('change', {bubbles: true})); + break; } };