Skip to content

Commit

Permalink
fix: Fixed an issue where URL sharing in TableDetail sometimes did no…
Browse files Browse the repository at this point in the history
…t work correctly
  • Loading branch information
MH4GF committed Dec 16, 2024
1 parent 90fae17 commit 7241265
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
6 changes: 6 additions & 0 deletions frontend/.changeset/twelve-impalas-type.md
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -12,9 +12,9 @@ import styles from './TableDetailDrawer.module.css'
const handleClose = () => updateActiveTableName(undefined)

export const TableDetailDrawerRoot: FC<PropsWithChildren> = ({ children }) => {
const {
active: { tableName },
} = useUserEditingStore()
const { tableName } = useUserEditingActiveStore()
const { tables } = useDBStructureStore()
const open = Object.keys(tables).length > 0 && tableName !== undefined

return (
<DrawerRoot
Expand All @@ -23,7 +23,7 @@ export const TableDetailDrawerRoot: FC<PropsWithChildren> = ({ 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}
Expand All @@ -33,9 +33,7 @@ export const TableDetailDrawerRoot: FC<PropsWithChildren> = ({ children }) => {

export const TableDetailDrawer: FC = () => {
const { tables } = useDBStructureStore()
const {
active: { tableName },
} = useUserEditingStore()
const { tableName } = useUserEditingActiveStore()
const table = tables[tableName ?? '']
const ariaDescribedBy =
table?.comment == null
Expand Down
1 change: 1 addition & 0 deletions frontend/packages/erd-core/src/stores/userEditing/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ import { useSnapshot } from 'valtio'
import { userEditingStore } from './store'

export const useUserEditingStore = () => useSnapshot(userEditingStore)
export const useUserEditingActiveStore = () => useSnapshot(userEditingStore.active)

0 comments on commit 7241265

Please sign in to comment.