MCPcopy Create free account
hub / github.com/angular/components / setDefaultState

Method setDefaultState

src/aria/private/tabs/tabs.ts:230–248  ·  view source on GitHub ↗

* Sets the tablist to its default initial state. * * Sets the active index of the tablist to the first focusable selected * tab if one exists. Otherwise, sets focus to the first focusable tab. * * This method should be called once the tablist and its tabs are properly initialized.

()

Source from the content-addressed store, hash-verified

228 * This method should be called once the tablist and its tabs are properly initialized.
229 */
230 setDefaultState() {
231 let firstItem: TabPattern | undefined;
232
233 for (const item of this.inputs.items()) {
234 if (!this.focusBehavior.isFocusable(item)) continue;
235
236 if (firstItem === undefined) {
237 firstItem = item;
238 }
239
240 if (item.selected()) {
241 this.inputs.activeItem.set(item);
242 return;
243 }
244 }
245 if (firstItem !== undefined) {
246 this.inputs.activeItem.set(firstItem);
247 }
248 }
249
250 /** Sets the default active state of the tablist before receiving interaction for the first time. */
251 setDefaultStateEffect(): void {

Callers 2

setDefaultStateEffectMethod · 0.95
tabs.spec.tsFile · 0.45

Calls 3

setMethod · 0.80
isFocusableMethod · 0.45
selectedMethod · 0.45

Tested by

no test coverage detected