diff --git a/packages/nc-gui-v2/components/cell/attachment/index.vue b/packages/nc-gui-v2/components/cell/attachment/index.vue index 33db7c7b83..28912f4314 100644 --- a/packages/nc-gui-v2/components/cell/attachment/index.vue +++ b/packages/nc-gui-v2/components/cell/attachment/index.vue @@ -4,7 +4,7 @@ import { useProvideAttachmentCell } from './utils' import { useSortable } from './sort' import Modal from './Modal.vue' import Carousel from './Carousel.vue' -import { computed, isImage, openLink, ref, useDropZone, useSmartsheetStoreOrThrow, watch } from '#imports' +import { computed, isImage, openLink, ref, useDropZone, useSmartsheetStoreOrThrow, watch, useSmartsheetRowStoreOrThrow } from '#imports' interface Props { modelValue: string | Record[] | null @@ -23,13 +23,15 @@ const sortableRef = ref() const { cellRefs } = useSmartsheetStoreOrThrow()! -const { column, modalVisible, attachments, visibleItems, onDrop, isLoading, open, FileIcon, selectedImage, isReadonly } = +const { column, modalVisible, attachments, visibleItems, onDrop, isLoading, open, FileIcon, selectedImage, isReadonly, storedFilesRefs, } = useProvideAttachmentCell(updateModelValue) const currentCellRef = computed(() => cellRefs.value.find((cell) => cell.dataset.key === `${rowIndex}${column.value.id}`)) const { dragging } = useSortable(sortableRef, visibleItems, updateModelValue, isReadonly) +const { state: rowState } = useSmartsheetRowStoreOrThrow() + const { isOverDropZone } = useDropZone(currentCellRef, onDrop) /** on new value, reparse our stored attachments */ @@ -53,6 +55,14 @@ onKeyDown('Escape', () => { modalVisible.value = false isOverDropZone.value = false }) + +/** sync storedFilesRefs state with row state */ +watch( + () => storedFilesRefs?.value?.length || 0, + () => { + rowState.value[column.value.title!] = storedFilesRefs?.value + }, +)