feat(material-experimental/mdc-chips): switch to evolution API#23931
Conversation
7ca6bb2 to
518c5b3
Compare
jelbourn
left a comment
There was a problem hiding this comment.
Got about halfway through so far
| @mixin _base-chip($is-dark) { | ||
| $on-surface-state-content: if($is-dark, mdc-color-palette.$grey-50, mdc-color-palette.$grey-900); | ||
| $surface: | ||
| color.mix(mdc-theme-color.prop-value(on-surface), mdc-theme-color.prop-value(surface), 12%); |
There was a problem hiding this comment.
Should we add a comment here to explain why we're doing the color mix?
There was a problem hiding this comment.
I don't think there's a good explanation tbh, we had the mixing there with the previous implementation so I moved it over to the new one.
| // which overrides our own handling. If we detect such a case, assign it to the same property | ||
| // as the Angular binding in order to maintain consistency. | ||
| if (name === 'tabindex') { | ||
| this._updateTabindex(parseInt(value)); |
There was a problem hiding this comment.
Should we use Number(value) here instead? IIRC Number is more predictable (e.g. doesn't interpret a leading 0 as octal)
There was a problem hiding this comment.
We've been using parseInt for cases like this everywhere else so I went along with it. I also think that it's unlikely for somebody to write out tabindex="007".
| // and error prone, and we need them in several places. | ||
| const classList = _elementRef.nativeElement.classList; | ||
| const actionType = this._foundation.actionType(); | ||
| classList.add('mdc-evolution-chip__action', 'mat-mdc-chip-action'); |
There was a problem hiding this comment.
I don't 100% follow- why not set these classes in the host block?
There was a problem hiding this comment.
There were two reasons when I was working on this initially:
- We still had to support ViewEngine which meant that I would've had to repeat the class bindings in two other places.
- I wouldn't have been able to use the enum values in the
hostblock.
I think that both of these issues are resolved with Ivy though.
| static ngAcceptInputType_disabled: BooleanInput; | ||
| static ngAcceptInputType_tabIndex: NumberInput; |
There was a problem hiding this comment.
We can drop these now, right?
There was a problem hiding this comment.
There were some internal issues with #23606 so I decided to keep them here.
| // MDC sets the tabindex directly on the DOM node when the user is navigating which means | ||
| // that we may end up with a `0` value from a previous interaction. We reset it manually | ||
| // here to ensure that the state is correct. |
There was a problem hiding this comment.
Should we file an issue for this?
There was a problem hiding this comment.
This is working as expected, as far as MDC is concerned. I don't think that it makes sense for people to customize the tabindex here to begin with, but we need it for backwards compatibility.
crisbeto
left a comment
There was a problem hiding this comment.
I've addressed the feedback so far.
| @mixin _base-chip($is-dark) { | ||
| $on-surface-state-content: if($is-dark, mdc-color-palette.$grey-50, mdc-color-palette.$grey-900); | ||
| $surface: | ||
| color.mix(mdc-theme-color.prop-value(on-surface), mdc-theme-color.prop-value(surface), 12%); |
There was a problem hiding this comment.
I don't think there's a good explanation tbh, we had the mixing there with the previous implementation so I moved it over to the new one.
| // which overrides our own handling. If we detect such a case, assign it to the same property | ||
| // as the Angular binding in order to maintain consistency. | ||
| if (name === 'tabindex') { | ||
| this._updateTabindex(parseInt(value)); |
There was a problem hiding this comment.
We've been using parseInt for cases like this everywhere else so I went along with it. I also think that it's unlikely for somebody to write out tabindex="007".
| // and error prone, and we need them in several places. | ||
| const classList = _elementRef.nativeElement.classList; | ||
| const actionType = this._foundation.actionType(); | ||
| classList.add('mdc-evolution-chip__action', 'mat-mdc-chip-action'); |
There was a problem hiding this comment.
There were two reasons when I was working on this initially:
- We still had to support ViewEngine which meant that I would've had to repeat the class bindings in two other places.
- I wouldn't have been able to use the enum values in the
hostblock.
I think that both of these issues are resolved with Ivy though.
| static ngAcceptInputType_disabled: BooleanInput; | ||
| static ngAcceptInputType_tabIndex: NumberInput; |
There was a problem hiding this comment.
There were some internal issues with #23606 so I decided to keep them here.
| // MDC sets the tabindex directly on the DOM node when the user is navigating which means | ||
| // that we may end up with a `0` value from a previous interaction. We reset it manually | ||
| // here to ensure that the state is correct. |
There was a problem hiding this comment.
This is working as expected, as far as MDC is concerned. I don't think that it makes sense for people to customize the tabindex here to begin with, but we need it for backwards compatibility.
518c5b3 to
cf23b4c
Compare
252953d to
809462b
Compare
82dba32 to
0f5247d
Compare
54124ef to
012edf4
Compare
62433de to
9f25785
Compare
|
Heads-up: I've pushed a second commit that simplifies the theming setup for the chips. The previous approach that was using the |
1020a33 to
496e5dd
Compare
Reworks the MDC-based chips to use the new `evolution` API instead of the deprecated one we're currently using. The new API comes with a lot of markup changes and some behavior differences. The new API also allows to remove the `GridKeyManager`, because the keyboard navigation is handled correctly by MDC.
…dle size Reworks the theme of the MDC-based chips to produce less specific and more compact CSS.
|
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. |
Reworks the MDC-based chips to use the new
evolutionAPI instead of the deprecated one we're currently using. The new API comes with a lot of markup changes and some behavior differences.The new API also allows to remove the
GridKeyManager, because the keyboard navigation is handled correctly by MDC.