Skip to content
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

fix(material-experimental/mdc-slider): append class to indicate short… #23566

Merged
merged 1 commit into from
Sep 16, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/material-experimental/mdc-slider/slider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ export interface MatSliderDragEvent {
styleUrls: ['slider-thumb.css'],
host: {
'class': 'mdc-slider__thumb mat-mdc-slider-visual-thumb',

// NOTE: This class is used internally.
// TODO(wagnermaciel): Remove this once it is handled by the mdc foundation (cl/388828896).
'[class.mdc-slider__thumb--short-value]': '_isShortValue()',
},
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
Expand Down Expand Up @@ -150,6 +154,11 @@ export class MatSliderVisualThumb implements AfterViewInit, OnDestroy {
this._elementRef.nativeElement.removeEventListener('mouseleave', this._onMouseLeave);
}

/** Used to append a class to indicate when the value indicator text is short. */
_isShortValue(): boolean {
return this.valueIndicatorText?.length <= 2;
Copy link
Member

Choose a reason for hiding this comment

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

nit: it might be a good idea to initialize the valueIndicatorText to an empty string so that we don't have to null check it everywhere. That would also make it easier to inline the entire expression in the host binding.

}

private _onMouseEnter = (): void => {
this._isHovered = true;
// We don't want to show the hover ripple on top of the focus ripple.
Expand Down