@angular/material 13.3.7 → 13.3.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/fesm2015/tabs.mjs CHANGED
@@ -11,8 +11,8 @@ import { InjectionToken, Directive, Inject, Optional, TemplateRef, Component, Ch
11
11
  import * as i4 from '@angular/material/core';
12
12
  import { mixinDisabled, mixinColor, mixinDisableRipple, mixinTabIndex, MAT_RIPPLE_GLOBAL_OPTIONS, RippleRenderer, MatCommonModule, MatRippleModule } from '@angular/material/core';
13
13
  import { ANIMATION_MODULE_TYPE } from '@angular/platform-browser/animations';
14
- import { take, startWith, distinctUntilChanged, takeUntil } from 'rxjs/operators';
15
- import { Subject, Subscription, fromEvent, of, merge, timer } from 'rxjs';
14
+ import { take, startWith, distinctUntilChanged, takeUntil, switchMap, skip } from 'rxjs/operators';
15
+ import { Subject, Subscription, fromEvent, of, merge, EMPTY, Observable, timer } from 'rxjs';
16
16
  import { trigger, state, style, transition, animate } from '@angular/animations';
17
17
  import * as i1 from '@angular/cdk/bidi';
18
18
  import { coerceNumberProperty, coerceBooleanProperty } from '@angular/cdk/coercion';
@@ -706,7 +706,7 @@ class MatPaginatedTabHeader {
706
706
  this._ngZone.onStable.pipe(take(1)).subscribe(realign);
707
707
  // On dir change or window resize, realign the ink bar and update the orientation of
708
708
  // the key manager if the direction has changed.
709
- merge(dirChange, resize, this._items.changes)
709
+ merge(dirChange, resize, this._items.changes, this._itemsResized())
710
710
  .pipe(takeUntil(this._destroyed))
711
711
  .subscribe(() => {
712
712
  // We need to defer this to give the browser some time to recalculate
@@ -729,6 +729,26 @@ class MatPaginatedTabHeader {
729
729
  this._setTabFocus(newFocusIndex);
730
730
  });
731
731
  }
732
+ /** Sends any changes that could affect the layout of the items. */
733
+ _itemsResized() {
734
+ if (typeof ResizeObserver !== 'function') {
735
+ return EMPTY;
736
+ }
737
+ return this._items.changes.pipe(startWith(this._items), switchMap((tabItems) => new Observable((observer) => this._ngZone.runOutsideAngular(() => {
738
+ const resizeObserver = new ResizeObserver(() => {
739
+ observer.next();
740
+ });
741
+ tabItems.forEach(item => {
742
+ resizeObserver.observe(item.elementRef.nativeElement);
743
+ });
744
+ return () => {
745
+ resizeObserver.disconnect();
746
+ };
747
+ }))),
748
+ // Skip the first emit since the resize observer emits when an item
749
+ // is observed for new items when the tab is already inserted
750
+ skip(1));
751
+ }
732
752
  ngAfterContentChecked() {
733
753
  // If the number of tab labels have changed, check if scrolling should be enabled
734
754
  if (this._tabLabelCount != this._items.length) {