11import React , { useCallback , useEffect , useMemo , useRef , useState } from 'react' ;
22
3- import { FieldType , useCellSelector , useFieldWrap , useReadOnly } from '@/application/database-yjs' ;
3+ import { FieldType , useCellSelector , useFieldWrap , useIsRowLoaded , useReadOnly } from '@/application/database-yjs' ;
44import { CellProps , Cell as CellType } from '@/application/database-yjs/cell.type' ;
55import { useFieldSelector } from '@/application/database-yjs/selector' ;
66import { FieldId , YjsDatabaseKey } from '@/application/types' ;
@@ -26,6 +26,7 @@ export function GridRowCell({ rowId, fieldId }: GridCellProps) {
2626 const isPrimary = field ?. get ( YjsDatabaseKey . is_primary ) ;
2727 const disableRelationRollupEdit = isFieldEditingDisabled ( fieldType as FieldType ) ;
2828 const isReadOnlyCell = readOnly || disableRelationRollupEdit ;
29+ const isRowLoaded = useIsRowLoaded ( rowId ) ;
2930 const cell = useCellSelector ( {
3031 rowId,
3132 fieldId,
@@ -118,6 +119,19 @@ export function GridRowCell({ rowId, fieldId }: GridCellProps) {
118119
119120 if ( ! field ) return null ;
120121
122+ // While the row's collab content is still loading from IndexedDB/network,
123+ // render blank non-primary cells. The primary cell renders a loading
124+ // indicator (handled inside PrimaryCell).
125+ if ( ! isRowLoaded && ! isPrimary ) {
126+ return (
127+ < div
128+ ref = { ref }
129+ data-testid = { `grid-cell-${ rowId } -${ fieldId } ` }
130+ className = { cn ( 'grid-cell flex h-full w-full items-start overflow-hidden px-2 text-sm' , paddingVertical ) }
131+ />
132+ ) ;
133+ }
134+
121135 return (
122136 < div
123137 ref = { ref }
0 commit comments