Skip to content

Commit

Permalink
Merge pull request #301 from liam-hq/sort-left-pane-tables
Browse files Browse the repository at this point in the history
🚸 Sort table nodes by name in LeftPane component
  • Loading branch information
MH4GF authored Dec 18, 2024
2 parents 5628eb0 + 5425848 commit 6be0528
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 6be0528

Please sign in to comment.