Skip to content

Commit

Permalink
🚸 Sort table nodes by name in LeftPane component
Browse files Browse the repository at this point in the history
  • Loading branch information
hoshinotsuyoshi committed Dec 18, 2024
1 parent 12d215f commit 5425848
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,19 @@ import { TableNameMenuButton } from './TableNameMenuButton'

export const LeftPane = () => {
const nodes = useNodes()
const tableNodes = useMemo(() => nodes.filter(isTableNode), [nodes])
const tableNodes = useMemo(() => {
return nodes.filter(isTableNode).sort((a, b) => {
const nameA = a.data.table.name
const nameB = b.data.table.name
if (nameA < nameB) {
return -1
}
if (nameA > nameB) {
return 1
}
return 0
})
}, [nodes])

return (
<Sidebar>
Expand Down

0 comments on commit 5425848

Please sign in to comment.