@eternalcodestudio/primeng-table 19.1.1 → 19.1.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.
@@ -1829,14 +1829,15 @@ class ECSPrimengTable {
1829
1829
  */
1830
1830
  onPredefinedFilterChange(filterName, selectedValues) {
1831
1831
  const filters = { ...this.dt.filters }; // Create a shallow copy of the current filters to avoid mutating the original filters directly
1832
+ const newValue = selectedValues && selectedValues.length ? selectedValues.map(value => value.value) : null; // Convert empty selection to null so PrimeNG removes the filter instead of applying an empty array
1832
1833
  if (Array.isArray(filters[filterName])) { // Check if the filter for the given filterName is an array
1833
1834
  filters[filterName].forEach(criteria => {
1834
- criteria.value = selectedValues.map(value => value.value); // Update the value of each criteria with the values from selectedValues
1835
+ criteria.value = newValue; // Update the value of each criteria with the values from selectedValues
1835
1836
  });
1836
1837
  }
1837
1838
  else if (filters[filterName]) { // Check if the filter for the given filterName exists and is not an array
1838
1839
  const criteria = filters[filterName]; // Cast the filter criteria to FilterMetadata
1839
- criteria.value = selectedValues.map(value => value.value); // Update the value of the criteria with the values from selectedValues
1840
+ criteria.value = newValue; // Update the value of the criteria with the values from selectedValues
1840
1841
  }
1841
1842
  this.dt.filters = filters; // Update the data table's filters with the modified filters object
1842
1843
  this.dt._filter(); // Trigger the filtering operation on the data table to apply the new filters
@@ -1965,9 +1966,9 @@ class ECSPrimengTable {
1965
1966
  if (!sameColumnsAsBefore) {
1966
1967
  this.tableOptions.isActive = false;
1967
1968
  this.clearSorts(this.dt, true);
1969
+ this.clearFilters(this.dt, true, false);
1968
1970
  setTimeout(() => {
1969
1971
  this.tableOptions.isActive = true;
1970
- this.clearSorts(this.dt, true);
1971
1972
  }, 1);
1972
1973
  }
1973
1974
  }