-
Notifications
You must be signed in to change notification settings - Fork 6.8k
feat(button-toggle): general component cleanup and support value input in multiple mode #9191
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
} | ||
set selected(selected: MatButtonToggle|MatButtonToggle[]|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.
We usually have spaces between the unioned types
} | ||
}) | ||
export class MatButtonToggleGroupMultiple extends _MatButtonToggleGroupMixinBase |
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.
This would be a major change since it totally removes the symbol; people may have been using @ViewChild
etc. to grab hold of these. Can we leave the symbol in as an alias for the combined one?
ce873ae
to
8af2daf
Compare
Addressed the feedback @jelbourn. |
private _vertical = false; | ||
private _multiple = false; | ||
private _selectionModel: SelectionModel<MatButtonToggle>; | ||
private _tempValue: any; |
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.
Add some comments about how this variable is used?
* @param isUserInput Whether the change was a result of a user interaction. | ||
*/ | ||
_syncButtonToggle(toggle: MatButtonToggle, select: boolean, isUserInput = false) { | ||
if (!this.multiple && this.selected && !toggle.checked) { |
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.
Why do we check !toggle.checked
here? add some comments?
/** | ||
* @deprecated Use `MatButtonToggleGroup` instead. | ||
*/ | ||
export class MatButtonToggleGroupMultiple {} |
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.
Add a unit test that queries for this?
8af2daf
to
2a27883
Compare
Addressed the feedback @tinayuangao @jelbourn. |
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
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
@crisbeto could you rebase this? |
2a27883
to
3cacceb
Compare
Rebased. |
3cacceb
to
4619d4b
Compare
Any updates on this one? @crisbeto @jelbourn @tinayuangao |
4619d4b
to
e7f04df
Compare
e7f04df
to
81d63df
Compare
|
||
/** Whether the toggle group is vertical. */ | ||
@Input() | ||
get vertical(): boolean { return this._vertical; } | ||
set vertical(value: boolean) { this._vertical = coerceBooleanProperty(value); } | ||
private _vertical: boolean = false; | ||
set vertical(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.
I think you have removed the type annotation here and in other places by accident, no?
7158d0e
to
6ff097d
Compare
ngAfterContentInit() { | ||
// If there was an attempt to assign a value before init, use it to set the | ||
// initial selection, otherwise check the `checked` state of the toggles. | ||
if (this._tempValue) { |
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.
We need this._tempValue !== null
here to accept 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.
Fixed.
6ff097d
to
c5da822
Compare
…t in multiple mode * Reworks the `MatButtonToggleGroup` component to remove the need for the `MatButtonToggleGroupMultiple` component and to avoid having to implement features in two places. * Reworks the `MatButtonToggleGroup` to use the `SelectionModel` for managing its state. * Switches all of the `async` button toggle tests to run in `fakeAsync`. As a side-effect of the above-mentioned changes, the toggle group in multiple mode now supports the same inputs as the one in single-selection mode (`value` input/output, `name` input, `change` event etc.). Note: this is along the same lines as angular#2773, however angular#2773 got left behind for too long and it would need a lot more work to fit in our current setup. Fixes angular#9058.
c5da822
to
79fcf6c
Compare
Thank you! This should resolve #1039 |
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. |
MatButtonToggleGroup
component to remove the need for theMatButtonToggleGroupMultiple
component and to avoid having to implement features in two places.MatButtonToggleGroup
to use theSelectionModel
for managing its state.async
button toggle tests to run infakeAsync
.As a side-effect of the above-mentioned changes, the toggle group in multiple mode now supports the same inputs as the one in single-selection mode (
value
input/output,name
input,change
event etc.).Note: this is along the same lines as #2773, however #2773 got left behind for too long and it would need a lot more work to fit in our current setup.
Fixes #9058.