File tree Expand file tree Collapse file tree
src/application/database-yjs/dispatch Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -578,7 +578,24 @@ export function useDuplicateRowDispatch() {
578578 if ( sourceDocId ) {
579579 // Check the dialog sub-doc cache first, then fall back to the
580580 // IndexedDB provider cache (used by full-page row editors).
581- const cachedDoc = getCachedRowSubDoc ( sourceDocId ) ?? getCachedProviderDoc ( sourceDocId ) ;
581+ // Important: the dialog sub-doc may be an empty shell if the user
582+ // typed content in full-page mode — in that case prefer the
583+ // provider doc which has the actual content.
584+ let cachedDoc = getCachedRowSubDoc ( sourceDocId ) ;
585+
586+ if ( cachedDoc ) {
587+ // Verify the sub-doc has real document content, not just empty structure
588+ const subDocRoot = cachedDoc . getMap ( YjsEditorKey . data_section ) ;
589+ const subDocDocument = subDocRoot ?. get ( YjsEditorKey . document ) as Y . Map < unknown > | undefined ;
590+ const subDocBlocks = subDocDocument ?. get ( YjsEditorKey . blocks ) as Y . Map < unknown > | undefined ;
591+
592+ if ( ! subDocBlocks || subDocBlocks . size <= 2 ) {
593+ // Dialog sub-doc is empty — try the provider doc instead
594+ cachedDoc = getCachedProviderDoc ( sourceDocId ) ?? cachedDoc ;
595+ }
596+ } else {
597+ cachedDoc = getCachedProviderDoc ( sourceDocId ) ?? null ;
598+ }
582599
583600 if ( cachedDoc ) {
584601 const docState = Y . encodeStateAsUpdate ( cachedDoc ) ;
You can’t perform that action at this time.
0 commit comments