Skip to content

Commit 24bb897

Browse files
fix: address PR review — stale closure in sort, false child indent for external refs
- handleModelSort: pass sortBy directly to sortModels instead of relying on async state - applyModelDecorations: filter references to only include sibling model names, ignore external table references
1 parent d9b9f27 commit 24bb897

1 file changed

Lines changed: 21 additions & 4 deletions

File tree

frontend/src/ide/explorer/explorer-component.jsx

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,16 +234,33 @@ const IdeExplorer = ({
234234
};
235235

236236
const applyModelDecorations = (models) => {
237+
// Build set of model names to distinguish from external table references
238+
const modelNames = new Set(models.map((m) => m.title));
237239
models.forEach((m) => {
238-
if ((m.references || []).length > 0) {
240+
const refs = (m.references || []).filter((r) => modelNames.has(r));
241+
if (refs.length > 0) {
239242
m._isChild = true;
240243
}
241244
});
242245
};
243246

244-
const handleModelSort = (key) => {
245-
setModelSortBy(key);
246-
rebuildTree();
247+
const handleModelSort = (sortBy) => {
248+
setModelSortBy(sortBy);
249+
if (rawTreeDataRef.current.length > 0) {
250+
const freshData = JSON.parse(JSON.stringify(rawTreeDataRef.current));
251+
freshData.forEach((node) => {
252+
if (node.title === "models" && node.children) {
253+
node.children.forEach((child) => {
254+
if (child.title === "no_code" && child.children) {
255+
child.children = sortModels(child.children, sortBy);
256+
applyModelDecorations(child.children);
257+
}
258+
});
259+
}
260+
});
261+
transformTree(freshData);
262+
setTreeData(freshData, false);
263+
}
247264
};
248265

249266
// Function to map string icons from API to actual icon components

0 commit comments

Comments
 (0)