Skip to content

Commit

Permalink
🐛 Fixed forever loading of related tables section for table without r…
Browse files Browse the repository at this point in the history
…elationships
  • Loading branch information
ya2s committed Feb 9, 2025
1 parent 3f564f5 commit 352bb52
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/serious-olives-watch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@liam-hq/erd-core": patch
---

🐛 Fixed forever loading of related tables section for table without relationships
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
addHiddenNodeIds,
updateActiveTableName,
updateShowMode,
useDBStructureStore,
} from '@/stores'
import {
getActiveTableNameFromUrl,
Expand All @@ -18,13 +19,16 @@ export const useInitialAutoLayout = (
nodes: Node[],
shouldFitViewToActiveTable: boolean,
) => {
const tableNodesInitialized = useMemo(
() =>
nodes
.filter((node) => node.type === 'table')
.some((node) => node.measured),
[nodes],
)
const dbStructure = useDBStructureStore()
const tableNodesInitialized = useMemo(() => {
const tableNodes = nodes.filter((node) => node.type === 'table')
const isInitializedDbStructure = Object.keys(dbStructure.tables).length > 0

return (
tableNodes.some((node) => node.measured) ||
(isInitializedDbStructure && tableNodes.length === 0)
)
}, [nodes, dbStructure.tables])
const { getEdges } = useReactFlow()

const {
Expand Down

0 comments on commit 352bb52

Please sign in to comment.