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

Method setDefaultState

src/aria/private/tabs/tabs.ts:227–245  ·  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

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