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

Function _setTabFocus

src/material/tabs/paginated-tab-header.ts:420–440  ·  view source on GitHub ↗

* Sets focus on the HTML element for the label wrapper and scrolls it into the view if * scrolling is enabled.

(tabIndex: number)

Source from the content-addressed store, hash-verified

418 * scrolling is enabled.
419 */
420 _setTabFocus(tabIndex: number) {
421 if (this._showPaginationControls) {
422 this._scrollToLabel(tabIndex);
423 }
424
425 if (this._items && this._items.length) {
426 this._items.toArray()[tabIndex].focus();
427
428 // Do not let the browser manage scrolling to focus the element, this will be handled
429 // by using translation. In LTR, the scroll left should be 0. In RTL, the scroll width
430 // should be the full width minus the offset width.
431 const containerEl = this._tabListContainer.nativeElement;
432 const dir = this._getLayoutDirection();
433
434 if (dir == 'ltr') {
435 containerEl.scrollLeft = 0;
436 } else {
437 containerEl.scrollLeft = containerEl.scrollWidth - containerEl.offsetWidth;
438 }
439 }
440 }
441
442 /** The layout direction of the containing app. */
443 _getLayoutDirection(): Direction {

Callers

nothing calls this directly

Calls 2

_getLayoutDirectionMethod · 0.80
focusMethod · 0.65

Tested by

no test coverage detected