fix(EditProductForm): prevent unnecessary flattening of empty child nodes
This commit is contained in:
@@ -71,7 +71,7 @@ export default function EditProductForm({ product, onSaved, onDeleted }: Props)
|
|||||||
for (const node of sorted) {
|
for (const node of sorted) {
|
||||||
const prefix = depth === 0 ? '' : depth === 1 ? '\u00a0\u00a0\u00a0↳ ' : '\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0↳ ';
|
const prefix = depth === 0 ? '' : depth === 1 ? '\u00a0\u00a0\u00a0↳ ' : '\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0↳ ';
|
||||||
result.push({ id: node.id, name: node.name, label: prefix + node.name });
|
result.push({ id: node.id, name: node.name, label: prefix + node.name });
|
||||||
result.push(...flattenTree(node.children, depth + 1));
|
if (node.children?.length) result.push(...flattenTree(node.children, depth + 1));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user