asab_webui_components 27.3.8 → 27.3.9

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.
@@ -116,7 +116,17 @@ var DataTableContextProvider = _ref => {
116
116
  updatedSearchParams.append(key, value);
117
117
  }
118
118
  });
119
- (0, _updateTableLimit.updateLimit)("decrease", updatedSearchParams);
119
+ /* Only decrease limit when adding the very first filtering.
120
+ Check original params (including the field being replaced) so that
121
+ replacing an existing filter does not decrease the limit a second time
122
+ */
123
+ var isFirstFilter = ![...searchParams.entries()].some(_ref2 => {
124
+ var [key] = _ref2;
125
+ return key.startsWith('a');
126
+ });
127
+ if (isFirstFilter) {
128
+ (0, _updateTableLimit.updateLimit)("decrease", updatedSearchParams);
129
+ }
120
130
  updatedSearchParams.set("p", 1);
121
131
  updatedSearchParams.append("a".concat(field), value);
122
132
  setSearchParams(updatedSearchParams);
@@ -129,7 +139,11 @@ var DataTableContextProvider = _ref => {
129
139
  updatedState[key] = prevState[key];
130
140
  }
131
141
  });
132
- (0, _updateTableLimit.updateStateLimit)("decrease", updatedState);
142
+ // Same check against the original prevState (before stripping the field)
143
+ var isFirstFilter = !Object.keys(prevState).some(key => key.startsWith('a'));
144
+ if (isFirstFilter) {
145
+ (0, _updateTableLimit.updateStateLimit)("decrease", updatedState);
146
+ }
133
147
  updatedState['p'] = 1;
134
148
  updatedState["a".concat(field)] = [value];
135
149
  return updatedState;
@@ -359,8 +373,8 @@ var DataTableContextProvider = _ref => {
359
373
 
360
374
  // Inner method to update search params
361
375
  var _updateSearchParams = (searchParams, params) => {
362
- Object.entries(params).forEach(_ref2 => {
363
- var [key, value] = _ref2;
376
+ Object.entries(params).forEach(_ref3 => {
377
+ var [key, value] = _ref3;
364
378
  searchParams.set(key, value);
365
379
  });
366
380
  return searchParams;
@@ -89,7 +89,14 @@ const DataTableContextProvider = ({ children, disableParams, initialLimit }) =>
89
89
  updatedSearchParams.append(key, value);
90
90
  }
91
91
  })
92
- updateLimit("decrease", updatedSearchParams);
92
+ /* Only decrease limit when adding the very first filtering.
93
+ Check original params (including the field being replaced) so that
94
+ replacing an existing filter does not decrease the limit a second time
95
+ */
96
+ const isFirstFilter = ![...searchParams.entries()].some(([key]) => key.startsWith('a'));
97
+ if (isFirstFilter) {
98
+ updateLimit("decrease", updatedSearchParams);
99
+ }
93
100
  updatedSearchParams.set("p", 1);
94
101
  updatedSearchParams.append(`a${field}`, value);
95
102
  setSearchParams(updatedSearchParams);
@@ -102,7 +109,11 @@ const DataTableContextProvider = ({ children, disableParams, initialLimit }) =>
102
109
  updatedState[key] = prevState[key];
103
110
  }
104
111
  });
105
- updateStateLimit("decrease", updatedState);
112
+ // Same check against the original prevState (before stripping the field)
113
+ const isFirstFilter = !Object.keys(prevState).some(key => key.startsWith('a'));
114
+ if (isFirstFilter) {
115
+ updateStateLimit("decrease", updatedState);
116
+ }
106
117
  updatedState['p'] = 1;
107
118
  updatedState[`a${field}`] = [value];
108
119
  return updatedState;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "asab_webui_components",
3
- "version": "27.3.8",
3
+ "version": "27.3.9",
4
4
  "license": "BSD-3-Clause",
5
5
  "description": "TeskaLabs ASAB WebUI Components Library",
6
6
  "contributors": [