components icon indicating copy to clipboard operation
components copied to clipboard

[P0] Replace global radio coordination and label listeners with a safe group model

Open Banegasn opened this issue 4 months ago • 1 comments

Objective

Eliminate document-global radio coordination and leaked label listeners while matching native radio group behavior.

Evidence

  • m3-radio-button.ts is 459 lines and installs document-level click and custom group-change listeners.
  • The add/remove calls for the capture click listener do not use matching capture options.
  • Multiple anonymous click listeners are added to discovered label/sibling elements and cannot be removed.
  • Group changes are broadcast on document, coupling independent trees/documents and creating avoidable global work.
  • There is no form-associated native group participation.

Scope

  • Replace global broadcasts with a scoped group/form algorithm.
  • Use a native internal radio or a dedicated m3-radio-group contract with roving tabindex and arrow navigation.
  • Implement safe label association without mutating/listening to arbitrary neighboring DOM nodes.
  • Ensure listener cleanup and behavior across shadow roots, forms, disabled items, dynamic insertion, and same-name groups.
  • Add lifecycle and interaction regression tests.

Acceptance criteria

  • [ ] No document-global custom radio event is used.
  • [ ] Connecting/disconnecting repeatedly leaves no listener or DOM mutation behind.
  • [ ] Same-name groups in different forms/roots do not affect one another.
  • [ ] Arrow keys, focus, checked state, change emission, and form values match the documented native-like contract.
  • [ ] External labels work through an explicit supported mechanism.

Dependencies

Blocked by the shared test/toolchain foundation; coordinate with the form-associated controls issue.

Autonomous execution contract

Do not patch the existing global listener approach incrementally. Replace it with a smaller scoped model and include before/after lifecycle tests.

Banegasn avatar Jul 13 '26 08:07 Banegasn

Prerequisite #7 is merged with a shared form-associated contract and Chromium/Firefox/WebKit browser execution. This P0 issue is now ready for its focused scoped-radio implementation. Clean-break policy remains in effect: no compatibility aliases or global-event shims.

Banegasn avatar Jul 29 '26 10:07 Banegasn