-
Notifications
You must be signed in to change notification settings - Fork 6.8k
feat(material-experimental/mdc-slider): implement the SliderAdapter #21844
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
feat(material-experimental/mdc-slider): implement the SliderAdapter #21844
Conversation
* complete the core logic for MatSliderThumb and MatSlider
@jelbourn are we allowed to use type-only imports? https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export that would probably help with the circular deps |
* delete commented out code * add comment explaining why emitChangeEvent and emitInputEvent are ignored
* remove circular dependency between MatSlider and MatSliderThumb * change the selectors for MatSliderThumb * add a comment describing why and how the value property on the MatSliderThumb works * delete min, max, and step @inputs from MatSliderThumb * remove _initialize property from MatSliderThumb * move all of the MatSliderThumb initialization logic into ngAfterViewInit * remove input initialization logic from MatSlider ngAfterViewInit * add input validation logic to MatSlider ngAfterViewInit * fix value indicator text bug where the DOM was not getting updated
* add todo to remember to add the mdc-slider back into the kitchen sink ssr app * move _foundation.init() into the _platform.isBrowser check to avoid ssr problems
} | ||
emitDragEndEvent(value: number, thumb: Thumb): void { | ||
throw Error('Method not implemented.'); | ||
getValueToAriaValueTextFn = (): ((value: number) => string) | 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.
Did we ever figure out why these have to be arrow functions instead of methods?
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.
Yes, MDC is clobbering them. I left a comment here explaining
https://github.com/angular/components/pull/21844/files#diff-f0898cf25f96d9c72cf31d7289a09209c713131e3268f7c96c27b35cc4be537bR39
* make input validation only happen in ngDevMode * move _validateInputs() and _throwInvalidInputConfigurationError() out of MatSlider so they can be tree-shaken away in production mode * delete _getValueIndicatorText() and _getValueIndicatorTextElement() and add their logic to _setValueIndicatorText() * made getters more efficient * deleted unused _getValue() method * move export class MatSliderThumb ... to its own separate line * moved MatSliderThumb value initialization to the constructor to avoid race conditions when setting the min and max * set the value property in ngAfterViewInit for MatSliderThumb
* move dummy MatSlider interfaces from slider-adapter and slider-thumb to slider-interface * create MatSliderThumb and MatSliderDragEvent dummy interfaces to avoid a circular dep between slider-thumb and slider-interface when defining the dummy MatSliderThumb interface * make MatSlider implement the dummy _MatSliderInterface
* add class description jsdoc * move comment explaining why we use arrow fns
4552321
to
2a98bf7
Compare
…r change detection problem * use markForCheck() instead of detectChanges() in updateTickMarks() * call detectChanges() once at the end of ngAfterViewInit() in MatSlider with a thorough comment explaining why it is needed
…r.ts * delete slider-adapter.ts * delete slider-interface.ts * delete slider-thumb.ts * move SliderAdapter implementation to slider.ts * move MatSliderThumb implementation to slider.ts * go back to using direct references instead of interfaces * fix imports in module.ts * fix imports in public-api.ts
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 with a couple API nits
* delete empty providers * rename thumb to _thumb and make it private in MatSliderThumb * delete thumb property in MatSliderDragEvent
@Output() readonly _focus: EventEmitter<void> = new EventEmitter<void>(); | ||
|
||
/** Indicates which slider thumb this input corresponds to. */ | ||
private _thumb: Thumb; |
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 would call this _thumbPosition
and the enum ThumbPosition
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.
The Thumb
enum comes from MDC
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.
Ack, I would still change the name of the property
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.
Ok. Would you also like me to make this change to all of the SliderAdapter
and MatSlider
methods that use thumb
as the name for this?
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.
Yeah, any properties/variables that refer to this concept I would name thumbPosition
since it's a much more clear description than thumb
(which I would assume is a reference to the actual thumb itself, not just the position)
* revert to using a method to display the value indicator text instead of directly through the DOM * avoid styling based on tag name and instead target class names applied to host elements * fix indentation in slider.scss * condense jsdoc to oneline * expand MatSliderThumb jsdoc * reworded comment in MatSliderThumb * move initialization of _thumb value to property definition * move input value attribute initialization to separate method * move input min and max property initialization to separate method * move input value property initialization to separate method * remove unnecessary !
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.
Overall LGTM aside from my last comment about the thumbPosition
a64bb8e
to
0558d5b
Compare
…ngular#21844) * feat(material-experimental/mdc-slider): implement the SliderAdapter * complete the core logic for MatSliderThumb and MatSlider * collapse slider-thumb.ts and slider-adapter.ts into slider.ts
…ngular#21844) * feat(material-experimental/mdc-slider): implement the SliderAdapter * complete the core logic for MatSliderThumb and MatSlider * collapse slider-thumb.ts and slider-adapter.ts into slider.ts
…ngular#21844) * feat(material-experimental/mdc-slider): implement the SliderAdapter * complete the core logic for MatSliderThumb and MatSlider * collapse slider-thumb.ts and slider-adapter.ts into slider.ts
…ngular#21844) * feat(material-experimental/mdc-slider): implement the SliderAdapter * complete the core logic for MatSliderThumb and MatSlider * collapse slider-thumb.ts and slider-adapter.ts into slider.ts
…ngular#21844) * feat(material-experimental/mdc-slider): implement the SliderAdapter * complete the core logic for MatSliderThumb and MatSlider * collapse slider-thumb.ts and slider-adapter.ts into slider.ts
…ngular#21844) * feat(material-experimental/mdc-slider): implement the SliderAdapter * complete the core logic for MatSliderThumb and MatSlider * collapse slider-thumb.ts and slider-adapter.ts into slider.ts
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. |
Uh oh!
There was an error while loading. Please reload this page.