Skip to content

Commit

Permalink
feature(web): Alphabetical sorting for lists. Fixes #315 (#351)
Browse files Browse the repository at this point in the history
* [Feature Request] Alphabetical sorting for lists #315
sorting lists alphabetical

* [Feature Request] Alphabetical sorting for lists #315
added sorting also for sublists
  • Loading branch information
kamtschatka authored Sep 15, 2024
1 parent 47939a5 commit 064d5f8
Showing 1 changed file with 24 additions and 20 deletions.
44 changes: 24 additions & 20 deletions apps/web/components/dashboard/lists/CollapsibleBookmarkLists.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,18 @@ function ListItem({
open,
})}
<CollapsibleContent>
{node.children.map((l) => (
<ListItem
isOpenFunc={isOpenFunc}
key={l.item.id}
node={l}
render={render}
level={level + 1}
className={className}
/>
))}
{node.children
.sort((a, b) => a.item.name.localeCompare(b.item.name))
.map((l) => (
<ListItem
isOpenFunc={isOpenFunc}
key={l.item.id}
node={l}
render={render}
level={level + 1}
className={className}
/>
))}
</CollapsibleContent>
</Collapsible>
);
Expand Down Expand Up @@ -96,16 +98,18 @@ export function CollapsibleBookmarkLists({

return (
<div>
{Object.values(root).map((l) => (
<ListItem
key={l.item.id}
node={l}
render={render}
level={0}
className={className}
isOpenFunc={isOpenFunc ?? (() => false)}
/>
))}
{Object.values(root)
.sort((a, b) => a.item.name.localeCompare(b.item.name))
.map((l) => (
<ListItem
key={l.item.id}
node={l}
render={render}
level={0}
className={className}
isOpenFunc={isOpenFunc ?? (() => false)}
/>
))}
</div>
);
}

0 comments on commit 064d5f8

Please sign in to comment.