Repository navigation
fix(material/radio): keep selections independent across forms - #34174
Open
sviat-barbutsa wants to merge 1 commit into
Open
sviat-barbutsa wants to merge 1 commit into
sviat-barbutsa wants to merge 1 commit into
Conversation
Scope radio selection to the owning form or DOM tree so selecting a value in one form preserves the other form's submitted value. Keep unscoped CDK selection notifications available to existing listeners. Fixes angular#5983
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5983. Thanks to @tinayuangao for the earlier work in #10129.
Problem & Fix
When two
<form>elements on the same page share a radio field name (e.g.,choice), selecting an option in the second form unchecks the native radio in the first. Even though the first form's Angular model still holds"email",new FormData(firstForm).get('choice')ends up returningnull. With this fix, both forms maintain their independent selections and submitemailandpostrespectively.<form>(or the root of their DOM tree if placed outside a form). Buttons sharing the same name and scope still uncheck each other, including standalonemat-radio-buttonelements alongside amat-radio-group.UniqueSelectionDispatcherbehavior intact so apps listening for a radio's ID and name continue receiving both. The new scope and listener filter are optional—callingnotify(id, name)still broadcasts to all listeners.Testing
mainin Chromium and Firefox."Email A radio button checked"with NVDA (compared to"not checked"onmain), while still reporting "Post B" as checked. Confirmed the same behavior with VoiceOver in Safari on macOS.