@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/fesm2020/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 * as i1 from '@angular/cdk/bidi';
17
17
  import { trigger, state, style, transition, animate } from '@angular/animations';
18
18
  import { coerceNumberProperty, coerceBooleanProperty } from '@angular/cdk/coercion';
@@ -694,7 +694,7 @@ class MatPaginatedTabHeader {
694
694
  this._ngZone.onStable.pipe(take(1)).subscribe(realign);
695
695
  // On dir change or window resize, realign the ink bar and update the orientation of
696
696
  // the key manager if the direction has changed.
697
- merge(dirChange, resize, this._items.changes)
697
+ merge(dirChange, resize, this._items.changes, this._itemsResized())
698
698
  .pipe(takeUntil(this._destroyed))
699
699
  .subscribe(() => {
700
700
  // We need to defer this to give the browser some time to recalculate
@@ -717,6 +717,26 @@ class MatPaginatedTabHeader {
717
717
  this._setTabFocus(newFocusIndex);
718
718
  });
719
719
  }
720
+ /** Sends any changes that could affect the layout of the items. */
721
+ _itemsResized() {
722
+ if (typeof ResizeObserver !== 'function') {
723
+ return EMPTY;
724
+ }
725
+ return this._items.changes.pipe(startWith(this._items), switchMap((tabItems) => new Observable((observer) => this._ngZone.runOutsideAngular(() => {
726
+ const resizeObserver = new ResizeObserver(() => {
727
+ observer.next();
728
+ });
729
+ tabItems.forEach(item => {
730
+ resizeObserver.observe(item.elementRef.nativeElement);
731
+ });
732
+ return () => {
733
+ resizeObserver.disconnect();
734
+ };
735
+ }))),
736
+ // Skip the first emit since the resize observer emits when an item
737
+ // is observed for new items when the tab is already inserted
738
+ skip(1));
739
+ }
720
740
  ngAfterContentChecked() {
721
741
  // If the number of tab labels have changed, check if scrolling should be enabled
722
742
  if (this._tabLabelCount != this._items.length) {