Skip to content

Commit

Permalink
Merge pull request #2371 from harnish7576/harnish7576/issue2342_displ…
Browse files Browse the repository at this point in the history
…ayed-values-ordering

Fixed displayed values ordering
  • Loading branch information
anth-volk authored Feb 28, 2025
2 parents 48e715d + e761aac commit 8fe2fc6
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/pages/PolicyPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,22 @@ function PolicyLeftSidebar(props) {
window.location.search.includes("focus=policyOutput") ||
window.location.search.includes("focus=householdOutput");

const sortTreeInPlace = (tree) => {
if (!Array.isArray(tree)) return [];

tree.sort((a, b) => a.label.localeCompare(b.label));

tree.forEach((item) => {
if (Array.isArray(item.children)) {
sortTreeInPlace(item.children);
}
});

return tree;
};

sortTreeInPlace(metadata.parameterTree.children);

// The menu, then the search bar anchored to the bottom
return (
<div style={{ backgroundColor: style.colors.LIGHT_GRAY }}>
Expand All @@ -82,7 +98,7 @@ function PolicyLeftSidebar(props) {
firstTree={metadata.parameterTree.children}
selected={selected}
onSelect={onSelect}
secondTree={POLICY_OUTPUT_TREE[0].children}
secondTree={POLICY_OUTPUT_TREE[0]?.children || []}
/>
</div>
);
Expand Down

0 comments on commit 8fe2fc6

Please sign in to comment.