Skip to content

Commit c386d0e

Browse files
authored
fix(cdk/listbox): coerce tabindex value (#31597)
Fixes that the CDK listbox option wasn't coercing its `tabindex` value. Fixes #31595.
1 parent 3dfe50a commit c386d0e

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

goldens/cdk/listbox/index.api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ export class CdkOption<T = unknown> implements ListKeyManagerOption, Highlightab
122122
// (undocumented)
123123
static ngAcceptInputType_disabled: unknown;
124124
// (undocumented)
125+
static ngAcceptInputType_enabledTabIndex: unknown;
126+
// (undocumented)
125127
ngOnDestroy(): void;
126128
select(): void;
127129
setActiveStyles(): void;

src/cdk/listbox/listbox.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import {
3939
inject,
4040
Input,
4141
NgZone,
42+
numberAttribute,
4243
OnDestroy,
4344
Output,
4445
QueryList,
@@ -130,7 +131,10 @@ export class CdkOption<T = unknown> implements ListKeyManagerOption, Highlightab
130131
private _disabled = signal(false);
131132

132133
/** The tabindex of the option when it is enabled. */
133-
@Input('tabindex')
134+
@Input({
135+
alias: 'tabindex',
136+
transform: (value: unknown) => (value == null ? undefined : numberAttribute(value)),
137+
})
134138
get enabledTabIndex() {
135139
return this._enabledTabIndex() === undefined
136140
? this.listbox.enabledTabIndex

0 commit comments

Comments
 (0)