From f0b22f7c53528e42717bdb403acf5d6c64bb18ef Mon Sep 17 00:00:00 2001 From: DarkPhoenix2704 Date: Wed, 24 Jul 2024 07:23:28 +0000 Subject: [PATCH] fix: add comments and review fixes --- .../components/cell/attachment/Carousel.vue | 37 ++++++++++--------- .../components/cell/attachment/index.vue | 2 +- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/packages/nc-gui/components/cell/attachment/Carousel.vue b/packages/nc-gui/components/cell/attachment/Carousel.vue index e9d4ce959b..ee9460fc65 100644 --- a/packages/nc-gui/components/cell/attachment/Carousel.vue +++ b/packages/nc-gui/components/cell/attachment/Carousel.vue @@ -45,7 +45,7 @@ const { getPossibleAttachmentSrc } = useAttachment() useEventListener(container, 'click', (e) => { const target = e.target as HTMLElement - if (!target.closest('.keep-open') && !target.closest('.nc-button') && !target?.closest('img') && !target?.closest('video')) { + if (!target.closest('.keep-open') && !target.closest('.nc-button') && !target.closest('img') && !target.closest('video')) { selectedFile.value = false } }) @@ -81,9 +81,12 @@ const goNext = () => { emblaThumbnailApi.value.scrollNext() } +// When the carousel is initialized, we set the selected index to the index of the selected file +// and scroll to that index. We only need to do this once, so we use watchOnce. watchOnce(emblaMainApi, async (emblaMainApi) => { if (!emblaMainApi) return + // The focus is set to the container so that the keyboard navigation works container.value?.focus() emblaThumbnailApi.value?.on('reInit', onSelect) @@ -131,7 +134,7 @@ function onKeyDown(event: KeyboardEvent) { /* const toggleComment = () => { openComments.value = !openComments.value -} */ +} onMounted(() => { if (!isPublic.value && !isExpandedFormOpen.value && isUIAllowed('commentList')) { @@ -139,6 +142,11 @@ onMounted(() => { loadComments() } }) +*/ + +const initEmblaApi = (val: any) => { + emblaMainApi.value = val +} + +