Skip to content

Commit 780a65a

Browse files
committed
fix(data-editor): insert new columns next to their group instead of at end
- Use findLastIndex to locate existing group members and splice after them - Fixes filtering panel showing new columns detached from their group - Apply same fix in export header rebuild path (io.js)
1 parent 9549ba3 commit 780a65a

2 files changed

Lines changed: 14 additions & 5 deletions

File tree

src/managers/io.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1506,7 +1506,13 @@ class IOManager {
15061506
(h) => h.subGroup === elem.subGroup && h.key === elem.key,
15071507
);
15081508
if (!exists) {
1509-
targetList.push(elem);
1509+
// Insert next to existing group members to keep groups contiguous
1510+
const lastGroupIdx = targetList.findLastIndex(h => h.subGroup === subGroup);
1511+
if (lastGroupIdx !== -1) {
1512+
targetList.splice(lastGroupIdx + 1, 0, elem);
1513+
} else {
1514+
targetList.push(elem);
1515+
}
15101516
}
15111517
}
15121518

src/utilities/data_editor.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -851,11 +851,14 @@ class DataTable {
851851
return;
852852
}
853853

854-
// Add to appropriate data headers list
855-
if (isNodeProperty) {
856-
this.fileData.nodeDataHeaders.push({ subGroup: groupName, key: propertyName });
854+
// Add to appropriate data headers list, inserting next to existing group members
855+
const targetHeaders = isNodeProperty ? this.fileData.nodeDataHeaders : this.fileData.edgeDataHeaders;
856+
const lastGroupIdx = targetHeaders.findLastIndex(h => h.subGroup === groupName);
857+
const newHeader = { subGroup: groupName, key: propertyName };
858+
if (lastGroupIdx !== -1) {
859+
targetHeaders.splice(lastGroupIdx + 1, 0, newHeader);
857860
} else {
858-
this.fileData.edgeDataHeaders.push({ subGroup: groupName, key: propertyName });
861+
targetHeaders.push(newHeader);
859862
}
860863

861864
// Reload tab data to rebuild headers with proper filtering

0 commit comments

Comments
 (0)