diff --git a/frontend/.changeset/twelve-impalas-type.md b/frontend/.changeset/twelve-impalas-type.md new file mode 100644 index 00000000..7f39b6d1 --- /dev/null +++ b/frontend/.changeset/twelve-impalas-type.md @@ -0,0 +1,6 @@ +--- +"@liam-hq/erd-core": patch +"@liam-hq/cli": patch +--- + +fix: Fixed an issue where URL sharing in TableDetail sometimes did not work correctly diff --git a/frontend/packages/erd-core/src/components/ERDRenderer/TableDetailDrawer/TableDetailDrawer.tsx b/frontend/packages/erd-core/src/components/ERDRenderer/TableDetailDrawer/TableDetailDrawer.tsx index c7042819..da89ed53 100644 --- a/frontend/packages/erd-core/src/components/ERDRenderer/TableDetailDrawer/TableDetailDrawer.tsx +++ b/frontend/packages/erd-core/src/components/ERDRenderer/TableDetailDrawer/TableDetailDrawer.tsx @@ -1,7 +1,7 @@ import { updateActiveTableName, useDBStructureStore, - useUserEditingStore, + useUserEditingActiveStore, } from '@/stores' import { DrawerContent, DrawerPortal, DrawerRoot } from '@liam-hq/ui' import type { FC, PropsWithChildren } from 'react' @@ -12,9 +12,9 @@ import styles from './TableDetailDrawer.module.css' const handleClose = () => updateActiveTableName(undefined) export const TableDetailDrawerRoot: FC = ({ children }) => { - const { - active: { tableName }, - } = useUserEditingStore() + const { tableName } = useUserEditingActiveStore() + const { tables } = useDBStructureStore() + const open = Object.keys(tables).length > 0 && tableName !== undefined return ( = ({ children }) => { // This behavior is an undocumented, unofficial usage and might change in the future. // ref: https://github.com/emilkowalski/vaul/blob/main/src/use-snap-points.ts snapPoints={[]} - open={tableName !== undefined} + open={open} onClose={handleClose} > {children} @@ -33,9 +33,7 @@ export const TableDetailDrawerRoot: FC = ({ children }) => { export const TableDetailDrawer: FC = () => { const { tables } = useDBStructureStore() - const { - active: { tableName }, - } = useUserEditingStore() + const { tableName } = useUserEditingActiveStore() const table = tables[tableName ?? ''] const ariaDescribedBy = table?.comment == null diff --git a/frontend/packages/erd-core/src/stores/userEditing/hooks.ts b/frontend/packages/erd-core/src/stores/userEditing/hooks.ts index 65afb6aa..add947bb 100644 --- a/frontend/packages/erd-core/src/stores/userEditing/hooks.ts +++ b/frontend/packages/erd-core/src/stores/userEditing/hooks.ts @@ -2,3 +2,4 @@ import { useSnapshot } from 'valtio' import { userEditingStore } from './store' export const useUserEditingStore = () => useSnapshot(userEditingStore) +export const useUserEditingActiveStore = () => useSnapshot(userEditingStore.active)