Skip to content

Commit 4d358f0

Browse files
committed
fix(data-editor): preserve group-contiguous column order in Excel export
Use filterDefaults key order instead of nodeExclusiveProps/edgeExclusiveProps Set iteration order, which interleaves groups due to per-node insertion. Fixes scrambled filter panel groups after Excel export → reimport.
1 parent 780a65a commit 4d358f0

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

src/utilities/data_editor.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1197,9 +1197,15 @@ class DataTable {
11971197
: `${key} [${subGroup}]`;
11981198
};
11991199

1200+
// Use filterDefaults key order (group-contiguous) instead of Set iteration order
1201+
const orderedNodeProps = [...this.cache.data.filterDefaults.keys()]
1202+
.filter(propId => this.cache.nodeExclusiveProps.has(propId));
1203+
const orderedEdgeProps = [...this.cache.data.filterDefaults.keys()]
1204+
.filter(propId => this.cache.edgeExclusiveProps.has(propId));
1205+
12001206
if (nodesToExport.length > 0) {
12011207
const nodesSheet = workbook.addWorksheet('nodes');
1202-
const nodesHeader = [...EXCEL_NODE_PROPERTIES.map(p => p.column), ...[...this.cache.nodeExclusiveProps].map(propIdToExcelHeader)];
1208+
const nodesHeader = [...EXCEL_NODE_PROPERTIES.map(p => p.column), ...orderedNodeProps.map(propIdToExcelHeader)];
12031209
nodesSheet.addRow(nodesHeader);
12041210

12051211
for (const node of nodesToExport) {
@@ -1214,7 +1220,7 @@ class DataTable {
12141220
row.push(value);
12151221
}
12161222

1217-
for (const customProp of this.cache.nodeExclusiveProps) {
1223+
for (const customProp of orderedNodeProps) {
12181224
const [group, subGroup, prop] = StaticUtilities.decodePropHashId(customProp);
12191225

12201226
const value = node.D4Data && node.D4Data[group] && node.D4Data[group][subGroup]
@@ -1229,7 +1235,7 @@ class DataTable {
12291235

12301236
if (edgesToExport.length > 0) {
12311237
const edgesSheet = workbook.addWorksheet('edges');
1232-
const edgesHeader = [...EXCEL_EDGE_PROPERTIES.map(p => p.column), ...[...this.cache.edgeExclusiveProps].map(propIdToExcelHeader)];
1238+
const edgesHeader = [...EXCEL_EDGE_PROPERTIES.map(p => p.column), ...orderedEdgeProps.map(propIdToExcelHeader)];
12331239
edgesSheet.addRow(edgesHeader);
12341240

12351241
for (const edge of edgesToExport) {
@@ -1240,7 +1246,7 @@ class DataTable {
12401246
row.push(value);
12411247
}
12421248

1243-
for (const customProp of this.cache.edgeExclusiveProps) {
1249+
for (const customProp of orderedEdgeProps) {
12441250
const [group, subGroup, prop] = StaticUtilities.decodePropHashId(customProp);
12451251

12461252
const value = edge.D4Data && edge.D4Data[group] && edge.D4Data[group][subGroup]

0 commit comments

Comments
 (0)