@fundamental-ngx/platform 0.62.3-rc.0 → 0.62.3-rc.2

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.
@@ -528,7 +528,7 @@ class SmartFilterBarOptionsDataProvider extends ArrayTableDataProvider {
528
528
  }
529
529
  /** @hidden */
530
530
  _getVisibleAndActiveItems() {
531
- return this.items.filter((i) => i.visible || i.active);
531
+ return this.items.filter((i) => i.visible && i.active);
532
532
  }
533
533
  /** @hidden */
534
534
  _getMandatoryItems() {
@@ -557,6 +557,10 @@ class SmartFilterBarSettingsDialogComponent {
557
557
  };
558
558
  /** @hidden */
559
559
  this._selectedFilters = [];
560
+ /** @hidden */
561
+ this._currentViewItems = [];
562
+ /** @hidden */
563
+ this._isRestoringSelection = false;
560
564
  /**
561
565
  * @hidden
562
566
  * An RxJS Subject that will kill the data stream upon component’s destruction (for unsubscribing)
@@ -582,11 +586,16 @@ class SmartFilterBarSettingsDialogComponent {
582
586
  .open()
583
587
  .pipe(observeOn(asyncScheduler), takeUntilDestroyed(this._destroyRef))
584
588
  .subscribe((items) => {
589
+ this._currentViewItems = items;
590
+ this._isRestoringSelection = true;
585
591
  items.forEach((field, index) => {
586
- if (field.visible) {
592
+ const shouldBeSelected = this._selectedFilters.includes(field.name);
593
+ const isCurrentlySelected = Boolean(this.table._tableRowsVisible[index]?.checked);
594
+ if (shouldBeSelected !== isCurrentlySelected) {
587
595
  this.table.toggleSelectableRow(index);
588
596
  }
589
597
  });
598
+ this._isRestoringSelection = false;
590
599
  });
591
600
  }
592
601
  /**
@@ -610,6 +619,7 @@ class SmartFilterBarSettingsDialogComponent {
610
619
  key: c.key,
611
620
  name: c.name
612
621
  }));
622
+ this._selectedFilters = this._availableFields.filter((f) => f.visible).map((f) => f.name);
613
623
  this.source = new TableDataSource(new SmartFilterBarOptionsDataProvider(this._availableFields));
614
624
  }
615
625
  /** @hidden */
@@ -622,7 +632,14 @@ class SmartFilterBarSettingsDialogComponent {
622
632
  }
623
633
  /** @hidden */
624
634
  _onRowSelectionChange(event) {
625
- this._selectedFilters = event.selection.map((c) => c.name);
635
+ if (this._isRestoringSelection) {
636
+ return;
637
+ }
638
+ const currentViewNames = new Set(this._currentViewItems.map((i) => i.name));
639
+ this._selectedFilters = [
640
+ ...this._selectedFilters.filter((name) => !currentViewNames.has(name)),
641
+ ...event.selection.map((c) => c.name)
642
+ ];
626
643
  this.isResetAvailable$.set(true);
627
644
  }
628
645
  /** @hidden */
@@ -630,6 +647,7 @@ class SmartFilterBarSettingsDialogComponent {
630
647
  if (!this.table) {
631
648
  return;
632
649
  }
650
+ this._isRestoringSelection = true;
633
651
  this.source.dataProvider.filter(event.payload);
634
652
  this.source.fetch(this.table.getTableState());
635
653
  }