Skip to content

Commit 04491a5

Browse files
committed
main - ce87e55 fix(material/slider): aria-valuetext host binding should be onPush compatible (#29042)
1 parent bd2195d commit 04491a5

File tree

6 files changed

+19
-14
lines changed

6 files changed

+19
-14
lines changed

esm2022/slider/slider-input.mjs

Lines changed: 6 additions & 4 deletions
Large diffs are not rendered by default.

esm2022/slider/slider-interface.mjs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

esm2022/slider/slider.mjs

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

fesm2022/slider.mjs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as i1 from '@angular/cdk/bidi';
22
import { Platform } from '@angular/cdk/platform';
33
import * as i0 from '@angular/core';
4-
import { InjectionToken, inject, Component, ChangeDetectionStrategy, ViewEncapsulation, Inject, Input, ViewChild, ANIMATION_MODULE_TYPE, booleanAttribute, numberAttribute, Optional, ViewChildren, ContentChild, ContentChildren, forwardRef, EventEmitter, Directive, Output, NgModule } from '@angular/core';
4+
import { InjectionToken, inject, Component, ChangeDetectionStrategy, ViewEncapsulation, Inject, Input, ViewChild, ANIMATION_MODULE_TYPE, booleanAttribute, numberAttribute, Optional, ViewChildren, ContentChild, ContentChildren, forwardRef, EventEmitter, signal, Directive, Output, NgModule } from '@angular/core';
55
import { RippleState, MatRipple, MAT_RIPPLE_GLOBAL_OPTIONS, MatCommonModule, MatRippleModule } from '@angular/material/core';
66
import { NG_VALUE_ACCESSOR } from '@angular/forms';
77
import { Subject } from 'rxjs';
@@ -745,7 +745,7 @@ class MatSlider {
745745
}
746746
const valuetext = this.displayWith(source.value);
747747
this._hasViewInitialized
748-
? (source._valuetext = valuetext)
748+
? source._valuetext.set(valuetext)
749749
: source._hostElement.setAttribute('aria-valuetext', valuetext);
750750
if (this.discrete) {
751751
source.thumbPosition === _MatThumb.START
@@ -1145,6 +1145,8 @@ class MatSliderThumb {
11451145
* @docs-private
11461146
*/
11471147
this.thumbPosition = _MatThumb.END;
1148+
/** The aria-valuetext string representation of the input's value. */
1149+
this._valuetext = signal('');
11481150
/** The radius of a native html slider's knob. */
11491151
this._knobRadius = 8;
11501152
/** The distance in px from the start of the slider track to the first tick mark. */
@@ -1448,7 +1450,7 @@ class MatSliderThumb {
14481450
this._hostElement.blur();
14491451
}
14501452
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.0-rc.0", ngImport: i0, type: MatSliderThumb, deps: [{ token: i0.NgZone }, { token: i0.ElementRef }, { token: i0.ChangeDetectorRef }, { token: MAT_SLIDER }], target: i0.ɵɵFactoryTarget.Directive }); }
1451-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "16.1.0", version: "18.0.0-rc.0", type: MatSliderThumb, isStandalone: true, selector: "input[matSliderThumb]", inputs: { value: ["value", "value", numberAttribute] }, outputs: { valueChange: "valueChange", dragStart: "dragStart", dragEnd: "dragEnd" }, host: { attributes: { "type": "range" }, listeners: { "change": "_onChange()", "input": "_onInput()", "blur": "_onBlur()", "focus": "_onFocus()" }, properties: { "attr.aria-valuetext": "_valuetext" }, classAttribute: "mdc-slider__input" }, providers: [
1453+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "16.1.0", version: "18.0.0-rc.0", type: MatSliderThumb, isStandalone: true, selector: "input[matSliderThumb]", inputs: { value: ["value", "value", numberAttribute] }, outputs: { valueChange: "valueChange", dragStart: "dragStart", dragEnd: "dragEnd" }, host: { attributes: { "type": "range" }, listeners: { "change": "_onChange()", "input": "_onInput()", "blur": "_onBlur()", "focus": "_onFocus()" }, properties: { "attr.aria-valuetext": "_valuetext()" }, classAttribute: "mdc-slider__input" }, providers: [
14521454
MAT_SLIDER_THUMB_VALUE_ACCESSOR,
14531455
{ provide: MAT_SLIDER_THUMB, useExisting: MatSliderThumb },
14541456
], exportAs: ["matSliderThumb"], ngImport: i0 }); }
@@ -1461,7 +1463,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.0-rc.0", ng
14611463
host: {
14621464
'class': 'mdc-slider__input',
14631465
'type': 'range',
1464-
'[attr.aria-valuetext]': '_valuetext',
1466+
'[attr.aria-valuetext]': '_valuetext()',
14651467
'(change)': '_onChange()',
14661468
'(input)': '_onInput()',
14671469
// TODO(wagnermaciel): Consider using a global event listener instead.

fesm2022/slider.mjs.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

slider/index.d.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { QueryList } from '@angular/core';
1313
import { RippleGlobalOptions } from '@angular/material/core';
1414
import { Subject } from 'rxjs';
1515
import { ThemePalette } from '@angular/material/core';
16+
import { WritableSignal } from '@angular/core';
1617

1718
declare namespace i2 {
1819
export {
@@ -410,7 +411,7 @@ export declare class MatSliderThumb implements _MatSliderThumb, OnDestroy, Contr
410411
/** The host native HTML input element. */
411412
_hostElement: HTMLInputElement;
412413
/** The aria-valuetext string representation of the input's value. */
413-
_valuetext: string;
414+
_valuetext: WritableSignal<string>;
414415
/** The radius of a native html slider's knob. */
415416
_knobRadius: number;
416417
/** The distance in px from the start of the slider track to the first tick mark. */
@@ -555,7 +556,7 @@ declare interface _MatSliderThumb {
555556
/** Whether the input is currently focused (either by tab or after clicking). */
556557
_isFocused: boolean;
557558
/** The aria-valuetext string representation of the input's value. */
558-
_valuetext: string;
559+
_valuetext: WritableSignal<string>;
559560
/**
560561
* Indicates whether UI updates should be skipped.
561562
*

0 commit comments

Comments
 (0)