Skip to content

Commit 164ad3c

Browse files
committed
fixup! fix(cdk-experimental/listbox): initial listbox focus state
1 parent c2019dc commit 164ad3c

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/cdk-experimental/listbox/listbox.ts

+7-6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*/
88

99
import {
10+
AfterViewInit,
1011
booleanAttribute,
1112
computed,
1213
contentChildren,
@@ -54,7 +55,7 @@ import {_IdGenerator} from '@angular/cdk/a11y';
5455
'(focusin)': 'onFocus()',
5556
},
5657
})
57-
export class CdkListbox<V> {
58+
export class CdkListbox<V> implements AfterViewInit {
5859
/** The directionality (LTR / RTL) context for the application (or a subtree of it). */
5960
private readonly _directionality = inject(Directionality);
6061

@@ -110,26 +111,26 @@ export class CdkListbox<V> {
110111
});
111112

112113
/** Whether the listbox has received focus yet. */
113-
private touched = signal(false);
114+
private _touched = signal(false);
114115

115116
/** Whether the options in the listbox have been initialized. */
116-
private isViewInitialized = signal(false);
117+
private _isViewInitialized = signal(false);
117118

118119
constructor() {
119120
effect(() => {
120-
if (this.isViewInitialized() && !this.touched()) {
121+
if (this._isViewInitialized() && !this._touched()) {
121122
const index = this.items().findIndex(i => this.value().includes(i.value()));
122123
this.activeIndex.set(Math.max(index, 0));
123124
}
124125
});
125126
}
126127

127128
ngAfterViewInit() {
128-
this.isViewInitialized.set(true);
129+
this._isViewInitialized.set(true);
129130
}
130131

131132
onFocus() {
132-
this.touched.set(true);
133+
this._touched.set(true);
133134
}
134135
}
135136

0 commit comments

Comments
 (0)