@porscheinformatik/material-addons 22.2.0 → 22.2.1

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.
@@ -2479,6 +2479,7 @@ class DataTableComponent {
2479
2479
  this._selectionModel = new SelectionModel(true);
2480
2480
  this._sort = null;
2481
2481
  this._pendingSort = null;
2482
+ this._awaitingAsyncSortedData = false;
2482
2483
  this.pageState = signal(DEFAULT_PAGE, ...(ngDevMode ? [{ debugName: "pageState" }] : []));
2483
2484
  this.dataLength = signal(0, ...(ngDevMode ? [{ debugName: "dataLength" }] : []));
2484
2485
  this._filterValue = signal(undefined, ...(ngDevMode ? [{ debugName: "_filterValue" }] : []));
@@ -2510,6 +2511,7 @@ class DataTableComponent {
2510
2511
  this.registerDisplayedColumnDefinitionEffect();
2511
2512
  this.registerForceSelectionModeEffect();
2512
2513
  this.registerAllColumnsEffect();
2514
+ this.registerAsyncDataSortSyncEffect();
2513
2515
  }
2514
2516
  registerMatSortEffect() {
2515
2517
  effect(() => {
@@ -2610,6 +2612,21 @@ class DataTableComponent {
2610
2612
  }
2611
2613
  });
2612
2614
  }
2615
+ registerAsyncDataSortSyncEffect() {
2616
+ effect(() => {
2617
+ this.tableData();
2618
+ untracked(() => {
2619
+ if (!this.useAsync() || !this.tableData()) {
2620
+ return;
2621
+ }
2622
+ if (this._awaitingAsyncSortedData) {
2623
+ this._awaitingAsyncSortedData = false;
2624
+ return;
2625
+ }
2626
+ this.clearSort();
2627
+ });
2628
+ });
2629
+ }
2613
2630
  /** TABLE DISPLAY HANDLING */
2614
2631
  getDataTableHeaderType(column) {
2615
2632
  if (column.isSortable && !column.isFilterable) {
@@ -2788,6 +2805,7 @@ class DataTableComponent {
2788
2805
  /** SORT HANDLING */
2789
2806
  onSortingEvent(sort) {
2790
2807
  if (this.useAsync()) {
2808
+ this._awaitingAsyncSortedData = true;
2791
2809
  this.sortEvent.emit(sort);
2792
2810
  }
2793
2811
  if (this.effectivePersistenceConfig().persistSort) {
@@ -2894,6 +2912,13 @@ class DataTableComponent {
2894
2912
  this.setSort(pendingSort);
2895
2913
  }
2896
2914
  }
2915
+ clearSort() {
2916
+ if (this.dataSource.sort) {
2917
+ this.dataSource.sort.active = '';
2918
+ this.dataSource.sort.direction = '';
2919
+ this.dataSource.sort._stateChanges.next();
2920
+ }
2921
+ }
2897
2922
  initFilterState() {
2898
2923
  const filter = this.persistenceService.loadFilter(this.id());
2899
2924
  this.filter()?.updateFilterables(filter);