Skip to content

Commit ec5986c

Browse files
crisbetowagnermaciel
authored andcommitted
fix: tabindex inputs not supporting coercion (#20037)
All the components that were implementing the `HasTabIndex` input weren't allowing coercion. Fixes #20026. (cherry picked from commit 333e609)
1 parent 16e8376 commit ec5986c

File tree

21 files changed

+32
-11
lines changed

21 files changed

+32
-11
lines changed

src/material-experimental/mdc-chips/chip-icons.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {BooleanInput} from '@angular/cdk/coercion';
9+
import {BooleanInput, NumberInput} from '@angular/cdk/coercion';
1010
import {ChangeDetectorRef, Directive, ElementRef, InjectionToken, OnDestroy} from '@angular/core';
1111
import {
1212
CanDisable,
@@ -197,4 +197,5 @@ export class MatChipRemove extends _MatChipRemoveMixinBase implements CanDisable
197197
}
198198

199199
static ngAcceptInputType_disabled: BooleanInput;
200+
static ngAcceptInputType_tabIndex: NumberInput;
200201
}

src/material-experimental/mdc-chips/chip-set.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
import {Directionality} from '@angular/cdk/bidi';
10-
import {BooleanInput, coerceBooleanProperty} from '@angular/cdk/coercion';
10+
import {BooleanInput, coerceBooleanProperty, NumberInput} from '@angular/cdk/coercion';
1111
import {
1212
AfterContentInit,
1313
AfterViewInit,
@@ -324,4 +324,5 @@ export class MatChipSet extends _MatChipSetMixinBase implements AfterContentInit
324324
}
325325

326326
static ngAcceptInputType_disabled: BooleanInput;
327+
static ngAcceptInputType_tabIndex: NumberInput;
327328
}

src/material-experimental/mdc-chips/chip.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
import {Directionality} from '@angular/cdk/bidi';
10-
import {BooleanInput, coerceBooleanProperty} from '@angular/cdk/coercion';
10+
import {BooleanInput, coerceBooleanProperty, NumberInput} from '@angular/cdk/coercion';
1111
import {ANIMATION_MODULE_TYPE} from '@angular/platform-browser/animations';
1212
import {
1313
AfterContentInit,
@@ -489,4 +489,5 @@ export class MatChip extends _MatChipMixinBase implements AfterContentInit, Afte
489489
static ngAcceptInputType_removable: BooleanInput;
490490
static ngAcceptInputType_highlighted: BooleanInput;
491491
static ngAcceptInputType_disableRipple: BooleanInput;
492+
static ngAcceptInputType_tabIndex: NumberInput;
492493
}

src/material/checkbox/checkbox.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
import {FocusableOption, FocusMonitor, FocusOrigin} from '@angular/cdk/a11y';
10-
import {BooleanInput, coerceBooleanProperty} from '@angular/cdk/coercion';
10+
import {BooleanInput, coerceBooleanProperty, NumberInput} from '@angular/cdk/coercion';
1111
import {
1212
AfterViewChecked,
1313
Attribute,
@@ -504,4 +504,5 @@ export class MatCheckbox extends _MatCheckboxMixinBase implements ControlValueAc
504504
static ngAcceptInputType_required: BooleanInput;
505505
static ngAcceptInputType_disableRipple: BooleanInput;
506506
static ngAcceptInputType_indeterminate: BooleanInput;
507+
static ngAcceptInputType_tabIndex: NumberInput;
507508
}

src/material/chips/chip.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
import {FocusableOption} from '@angular/cdk/a11y';
10-
import {BooleanInput, coerceBooleanProperty} from '@angular/cdk/coercion';
10+
import {BooleanInput, coerceBooleanProperty, NumberInput} from '@angular/cdk/coercion';
1111
import {BACKSPACE, DELETE, SPACE} from '@angular/cdk/keycodes';
1212
import {Platform} from '@angular/cdk/platform';
1313
import {DOCUMENT} from '@angular/common';
@@ -454,6 +454,7 @@ export class MatChip extends _MatChipMixinBase implements FocusableOption, OnDes
454454
static ngAcceptInputType_removable: BooleanInput;
455455
static ngAcceptInputType_disabled: BooleanInput;
456456
static ngAcceptInputType_disableRipple: BooleanInput;
457+
static ngAcceptInputType_tabIndex: NumberInput;
457458
}
458459

459460
/**

src/material/core/common-behaviors/tabindex.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9+
import {coerceNumberProperty} from '@angular/cdk/coercion';
910
import {Constructor} from './constructor';
1011
import {CanDisable} from './disabled';
1112

@@ -28,7 +29,7 @@ export function mixinTabIndex<T extends Constructor<CanDisable>>(base: T, defaul
2829
get tabIndex(): number { return this.disabled ? -1 : this._tabIndex; }
2930
set tabIndex(value: number) {
3031
// If the specified tabIndex value is null or undefined, fall back to the default value.
31-
this._tabIndex = value != null ? value : defaultTabIndex;
32+
this._tabIndex = value != null ? coerceNumberProperty(value) : defaultTabIndex;
3233
}
3334

3435
constructor(...args: any[]) {

src/material/radio/radio.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
import {FocusMonitor} from '@angular/cdk/a11y';
10-
import {BooleanInput, coerceBooleanProperty} from '@angular/cdk/coercion';
10+
import {BooleanInput, coerceBooleanProperty, NumberInput} from '@angular/cdk/coercion';
1111
import {UniqueSelectionDispatcher} from '@angular/cdk/collections';
1212
import {
1313
AfterContentInit,
@@ -599,6 +599,7 @@ export abstract class _MatRadioButtonBase extends _MatRadioButtonMixinBase imple
599599
static ngAcceptInputType_disabled: BooleanInput;
600600
static ngAcceptInputType_required: BooleanInput;
601601
static ngAcceptInputType_disableRipple: BooleanInput;
602+
static ngAcceptInputType_tabIndex: NumberInput;
602603
}
603604

604605

src/material/select/select.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,4 +1406,5 @@ export class MatSelect extends _MatSelectMixinBase implements AfterContentInit,
14061406
static ngAcceptInputType_typeaheadDebounceInterval: NumberInput;
14071407
static ngAcceptInputType_disabled: BooleanInput;
14081408
static ngAcceptInputType_disableRipple: BooleanInput;
1409+
static ngAcceptInputType_tabIndex: NumberInput;
14091410
}

src/material/slide-toggle/slide-toggle.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
import {FocusMonitor} from '@angular/cdk/a11y';
10-
import {BooleanInput, coerceBooleanProperty} from '@angular/cdk/coercion';
10+
import {BooleanInput, coerceBooleanProperty, NumberInput} from '@angular/cdk/coercion';
1111
import {
1212
AfterContentInit,
1313
Attribute,
@@ -285,4 +285,5 @@ export class MatSlideToggle extends _MatSlideToggleMixinBase implements OnDestro
285285
static ngAcceptInputType_checked: BooleanInput;
286286
static ngAcceptInputType_disabled: BooleanInput;
287287
static ngAcceptInputType_disableRipple: BooleanInput;
288+
static ngAcceptInputType_tabIndex: NumberInput;
288289
}

src/material/slider/slider.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -902,6 +902,7 @@ export class MatSlider extends _MatSliderMixinBase
902902
static ngAcceptInputType_value: NumberInput;
903903
static ngAcceptInputType_vertical: BooleanInput;
904904
static ngAcceptInputType_disabled: BooleanInput;
905+
static ngAcceptInputType_tabIndex: NumberInput;
905906
}
906907

907908
/** Returns whether an event is a touch event. */

0 commit comments

Comments
 (0)