Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix(material/button-toggle): make null value selected on init #25553

Merged

Conversation

kush-savani
Copy link
Contributor

@kush-savani kush-savani commented Aug 30, 2022

When button-toggle have init value as null, it's not get selected. This fix remove condition which stopping null button to select.
FYI: there is no null check on the value of the radio buttons for selection. Ref

Fixes #25472

Copy link
Contributor

@zarend zarend left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the value of a button toggle group is an any, which means it doesn't have to be a string. For that reason, this PR looks reasonable to me.

  /** MatButtonToggleGroup reads this to assign its own value. */
  @Input() value: any;

@josephperrott josephperrott requested a review from a team as a code owner December 18, 2024 17:40
@josephperrott josephperrott requested review from crisbeto and removed request for a team December 18, 2024 17:40
@mmalerba mmalerba self-assigned this Jan 22, 2025
When button-toggle have init value as null, it's not get selected. This fix remove condition which stopping null button to select.

Fixes angular#25472
@mmalerba mmalerba force-pushed the button-toggle-default-value-seletion branch from 5fc95ba to 829d053 Compare January 29, 2025 18:14
@mmalerba mmalerba added the action: merge The PR is ready for merge by the caretaker label Jan 30, 2025
@mmalerba mmalerba added the target: patch This PR is targeted for the next patch release label Jan 30, 2025
@mmalerba mmalerba merged commit 9ea468a into angular:main Jan 30, 2025
24 of 26 checks passed
@mmalerba
Copy link
Contributor

The changes were merged into the following branches: main, 19.1.x

mmalerba pushed a commit that referenced this pull request Jan 30, 2025
When button-toggle have init value as null, it's not get selected. This fix remove condition which stopping null button to select.

Fixes #25472

(cherry picked from commit 9ea468a)
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
action: merge The PR is ready for merge by the caretaker area: material/button-toggle target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug(MatButtonToggle): Button with undefined or null value not selected by default
3 participants