-
Notifications
You must be signed in to change notification settings - Fork 6.8k
fix(button-toggle): fix button toggle with 0 value not checked #11292
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| if (this.multiple && Array.isArray(this._rawValue)) { | ||
| return !!this._rawValue.find(value => toggle.value != null && value === toggle.value); | ||
| const match = this._rawValue.find(value => toggle.value != null && value === toggle.value); | ||
| return typeof match !== 'undefined'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should be able to do return match != null, which will capture null and undefined without any of the other falsy values
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Updated
2564617 to
5ba2f69
Compare
crisbeto
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, one nit.
| if (this.multiple && Array.isArray(this._rawValue)) { | ||
| return !!this._rawValue.find(value => toggle.value != null && value === toggle.value); | ||
| const match = this._rawValue.find(value => toggle.value != null && value === toggle.value); | ||
| return match != null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can just return here: return !!this._rawValue.find(...).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found returning !!this._rawValue doesn't work.
Changed to null != this._rawValue.find....
5ba2f69 to
eb47e91
Compare
|
|
||
| if (this.multiple && Array.isArray(this._rawValue)) { | ||
| return !!this._rawValue.find(value => toggle.value != null && value === toggle.value); | ||
| return null != this._rawValue.find(value => toggle.value != null && value === toggle.value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you only care about the presence of the value, you can use some instead of find:
return this._rawValue.some(v => toggle.value != null && v === toggle.value);There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Updated.
eb47e91 to
b5ca77f
Compare
jelbourn
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |

Fixes #11279