mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-24 04:27:27 +08:00
fix(core): database properties in info flickering issue (#9872)
fix af-2123
This commit is contained in:
@@ -29,7 +29,7 @@ import {
|
|||||||
} from '@toeverything/infra';
|
} from '@toeverything/infra';
|
||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
import type React from 'react';
|
import type React from 'react';
|
||||||
import { forwardRef, useCallback, useState } from 'react';
|
import { forwardRef, useCallback, useMemo, useState } from 'react';
|
||||||
|
|
||||||
import { DocPropertyIcon } from './icons/doc-property-icon';
|
import { DocPropertyIcon } from './icons/doc-property-icon';
|
||||||
import { CreatePropertyMenuItems } from './menu/create-doc-property';
|
import { CreatePropertyMenuItems } from './menu/create-doc-property';
|
||||||
@@ -401,6 +401,17 @@ const DocPropertiesTableInner = ({
|
|||||||
className,
|
className,
|
||||||
}: DocPropertiesTableProps) => {
|
}: DocPropertiesTableProps) => {
|
||||||
const [expanded, setExpanded] = useState(!!defaultOpenProperty);
|
const [expanded, setExpanded] = useState(!!defaultOpenProperty);
|
||||||
|
const defaultOpen = useMemo(() => {
|
||||||
|
return defaultOpenProperty?.type === 'database'
|
||||||
|
? [
|
||||||
|
{
|
||||||
|
databaseBlockId: defaultOpenProperty.databaseId,
|
||||||
|
rowId: defaultOpenProperty.databaseRowId,
|
||||||
|
docId: defaultOpenProperty.docId,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
: [];
|
||||||
|
}, [defaultOpenProperty]);
|
||||||
return (
|
return (
|
||||||
<div className={clsx(styles.root, className)}>
|
<div className={clsx(styles.root, className)}>
|
||||||
<Collapsible.Root open={expanded} onOpenChange={setExpanded}>
|
<Collapsible.Root open={expanded} onOpenChange={setExpanded}>
|
||||||
@@ -421,17 +432,7 @@ const DocPropertiesTableInner = ({
|
|||||||
<div className={styles.tableHeaderDivider} />
|
<div className={styles.tableHeaderDivider} />
|
||||||
<DocDatabaseBacklinkInfo
|
<DocDatabaseBacklinkInfo
|
||||||
onChange={onDatabasePropertyChange}
|
onChange={onDatabasePropertyChange}
|
||||||
defaultOpen={
|
defaultOpen={defaultOpen}
|
||||||
defaultOpenProperty?.type === 'database'
|
|
||||||
? [
|
|
||||||
{
|
|
||||||
databaseBlockId: defaultOpenProperty.databaseId,
|
|
||||||
rowId: defaultOpenProperty.databaseRowId,
|
|
||||||
docId: defaultOpenProperty.docId,
|
|
||||||
},
|
|
||||||
]
|
|
||||||
: []
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
</Collapsible.Content>
|
</Collapsible.Content>
|
||||||
</Collapsible.Root>
|
</Collapsible.Root>
|
||||||
|
|||||||
Reference in New Issue
Block a user