Skip to content

Commit 8b4ed4c

Browse files
feat(stories): Sort folders first (#68993)
<img alt="clipboard.png" width="301" src="https://i.imgur.com/MLdTnTG.png" />
1 parent 5b4f74c commit 8b4ed4c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

static/app/views/stories/storyTree.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,14 @@ function FolderContent({path, content}: {content: TreeMapping; path: string}) {
2525
const location = useLocation<StoriesQuery>();
2626
const currentFile = location.query.name;
2727

28+
// sort folders to the top
29+
const entries = Object.entries(content).sort(
30+
(a, b) => Number(!!Object.keys(b[1]).length) - Number(!!Object.keys(a[1]).length)
31+
);
32+
2833
return (
2934
<UnorderedList>
30-
{Object.entries(content).map(([name, children]) => {
35+
{entries.map(([name, children]) => {
3136
const childPath = toPath(path, name);
3237

3338
if (Object.keys(children).length === 0) {

0 commit comments

Comments
 (0)