Skip to content

Commit

Permalink
Sort variables alphabetically (#1154)
Browse files Browse the repository at this point in the history
  • Loading branch information
shueja authored Jan 22, 2025
1 parent 49f7130 commit d284680
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ const PoseVariablesConfigPanel = observer(() => {
doc.variables.poses.keys();
return (
<>
{Array.from(doc.variables.poses.entries()).map((entry) => (
{doc.variables.sortedPoses.map((entry) => (
<OpenablePoseVariablePanel
entry={entry}
setName={(name) => doc.variables.renamePose(entry[0], name)}
Expand Down
2 changes: 1 addition & 1 deletion src/components/config/variables/VariablesConfigPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ const VariablesConfigPanel = observer(() => {
doc.variables.expressions.keys();
return (
<>
{Array.from(doc.variables.expressions.entries()).map((entry) => (
{doc.variables.sortedExpressions.map((entry) => (
<VariablePanel
validateName={(name) => doc.variables.validateName(name, entry[0])}
logo={() => (
Expand Down
16 changes: 16 additions & 0 deletions src/document/ExpressionStore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,22 @@ export const Variables = types
vars.set(key, val.asScope);
}
return vars;
},
get sortedExpressions(): Array<[string, IExpressionStore]> {
return Array.from(self.expressions.entries()).sort((a, b) =>
a[0].toLocaleUpperCase() > b[0].toLocaleUpperCase() ? 1 : -1
);
},
get sortedExpressionKeys(): Array<string> {
return this.sortedExpressions.map(([key, _]) => key);
},
get sortedPoses(): Array<[string, IExprPose]> {
return Array.from(self.poses.entries()).sort((a, b) =>
a[0].toLocaleUpperCase() > b[0].toLocaleUpperCase() ? 1 : -1
);
},
get sortedPoseKeys(): Array<string> {
return this.sortedPoses.map(([key, _]) => key);
}
}))
.actions((self) => ({
Expand Down

0 comments on commit d284680

Please sign in to comment.