-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
issue-1687/sorted orgs in menu #1706
Conversation
const sortedTreeItems = useMemo(() => { | ||
const sorted = treeItemData.sort((a, b) => a.title.localeCompare(b.title)); | ||
return sorted; | ||
}, [treeItemData.length]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct me if I'm wrong, but I believe this only sorts the top-level, which is not enough. We also want to sort the children of each organization, and all of the children of those children, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aaaah yeah you are right. I will add more logic to it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the best solution would be to handle the sorting in the rendering of each "level", rather than here in the top-level.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! The code looks mostly good and I have verified that it works as expected. You can decide if you want to merge or change the variable name issue I've pointed out below.
I foresee this code being refactored in the near future, so you don't have to fix the problem below if you struggle to find the time for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Description
This PR sorts organizations alphabetically in menu
Screenshots
Changes
useMemo
and sort listNotes to reviewer
used
useMemo
to prevent the sorting from being triggered every time user moves a cursor to the sidebar.Related issues
Resolves #1687