playbook_ui 14.22.0.pre.alpha.PLAY2292advancedtablepinnedrowsloading8632 → 14.22.0.pre.alpha.PLAY2292advancedtablepinnedrowsloading8633
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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50940c977e833de1ec35e25c6269e332057fc06778dd67d44d2e59ab4ddd799e
|
4
|
+
data.tar.gz: def4a38171d0f1a0a97bcf80ddb277491d34b5661bcdb2d83b5f7c53c7bc9497
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 492530c127fd34e4edaf65b5afea93df1c41ebe96fd62aaffc2d398ba788cd88d6703175c406c62c6e9bd024f0bdf45f7a2b5ade54e44691a86c63c01556562f
|
7
|
+
data.tar.gz: dba59d34834a6c95d44fa1253641a2d29eccc7762abe866903f30948a04260fce9bf4393e5c4f013cf4ac58252210ac40606c436be76208d2eef2db4e119573c
|
@@ -188,16 +188,28 @@ export function useTableState({
|
|
188
188
|
}, [tableData, dataChunk, virtualizedRows, loading]);
|
189
189
|
|
190
190
|
const [prevDataHash, setPrevDataHash] = useState(dataHash);
|
191
|
-
|
192
|
-
//
|
193
|
-
|
194
|
-
|
191
|
+
|
192
|
+
// Synchronously clear pins when data changes to prevent table errors
|
193
|
+
if (!loading && dataHash !== prevDataHash) {
|
194
|
+
setPrevDataHash(dataHash);
|
195
195
|
|
196
|
-
|
197
|
-
|
198
|
-
|
196
|
+
const currentPins = pinnedRows?.value?.top ?? [];
|
197
|
+
if (currentPins.length > 0) {
|
198
|
+
try {
|
199
|
+
const currentData = virtualizedRows ? dataChunk : tableData;
|
200
|
+
const validPins = currentPins.filter(id =>
|
201
|
+
currentData.some(row => row.id === id)
|
202
|
+
);
|
203
|
+
|
204
|
+
if (validPins.length !== currentPins.length) {
|
205
|
+
onRowPinningChange({ top: validPins });
|
206
|
+
}
|
207
|
+
} catch (error) {
|
208
|
+
console.warn('Error validating pins on data change, clearing pins:', error);
|
209
|
+
onRowPinningChange({ top: [] });
|
210
|
+
}
|
199
211
|
}
|
200
|
-
}
|
212
|
+
}
|
201
213
|
|
202
214
|
// Handle row pinning changes
|
203
215
|
useEffect(() => {
|
@@ -208,17 +220,48 @@ export function useTableState({
|
|
208
220
|
onRowPinningChange({ top: [] });
|
209
221
|
return;
|
210
222
|
}
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
223
|
+
|
224
|
+
try {
|
225
|
+
const rows = table.getRowModel().rows;
|
226
|
+
|
227
|
+
const validPinnedIds = topPins.filter(id => {
|
228
|
+
try {
|
229
|
+
return rows.some(row => row.id === id && row.depth === 0);
|
230
|
+
} catch (error) {
|
231
|
+
console.warn(`Pinned row with id ${id} not found in current dataset`);
|
232
|
+
return false;
|
233
|
+
}
|
234
|
+
});
|
235
|
+
|
236
|
+
if (validPinnedIds.length === 0) {
|
237
|
+
onRowPinningChange({ top: [] });
|
238
|
+
return;
|
219
239
|
}
|
220
|
-
|
221
|
-
|
240
|
+
|
241
|
+
const collectAllDescendantIds = (subs: Row<GenericObject>[]): string[] =>
|
242
|
+
subs.flatMap(r => [r.id, ...collectAllDescendantIds(r.subRows)]);
|
243
|
+
|
244
|
+
const allPinned: string[] = [];
|
245
|
+
|
246
|
+
validPinnedIds.forEach(id => {
|
247
|
+
const parent = rows.find(r => r.id === id && r.depth === 0);
|
248
|
+
if (parent) {
|
249
|
+
allPinned.push(parent.id, ...collectAllDescendantIds(parent.subRows));
|
250
|
+
}
|
251
|
+
});
|
252
|
+
|
253
|
+
const currentPins = pinnedRows?.value?.top ?? [];
|
254
|
+
const pinsChanged = allPinned.length !== currentPins.length ||
|
255
|
+
!allPinned.every(id => currentPins.includes(id));
|
256
|
+
|
257
|
+
if (pinsChanged) {
|
258
|
+
onRowPinningChange({ top: allPinned });
|
259
|
+
}
|
260
|
+
|
261
|
+
} catch (error) {
|
262
|
+
console.error('Error in pinned rows logic:', error);
|
263
|
+
onRowPinningChange({ top: [] });
|
264
|
+
}
|
222
265
|
}, [table, pinnedRows?.value?.top?.join(','), loading]);
|
223
266
|
|
224
267
|
// Check if table has any sub-rows
|