diff --git a/app/assets/javascripts/Components/AttachedFilesPopover/AttachedFilesButton.tsx b/app/assets/javascripts/Components/AttachedFilesPopover/AttachedFilesButton.tsx index 08ab451d069..8c878d8025f 100644 --- a/app/assets/javascripts/Components/AttachedFilesPopover/AttachedFilesButton.tsx +++ b/app/assets/javascripts/Components/AttachedFilesPopover/AttachedFilesButton.tsx @@ -13,9 +13,10 @@ import { confirmDialog } from '@/Services/AlertService' import { addToast, dismissToast, ToastType } from '@standardnotes/stylekit' import { StreamingFileReader } from '@standardnotes/filepicker' import { PopoverFileItemAction, PopoverFileItemActionType } from './PopoverFileItemAction' -import { AttachedFilesPopover, PopoverTabs } from './AttachedFilesPopover' +import { AttachedFilesPopover } from './AttachedFilesPopover' import { usePremiumModal } from '@/Hooks/usePremiumModal' import { useFilePreviewModal } from '../Files/FilePreviewModalProvider' +import { PopoverTabs } from './PopoverTabs' type Props = { application: WebApplication @@ -23,21 +24,6 @@ type Props = { onClickPreprocessing?: () => Promise } -const createDragOverlay = () => { - if (document.getElementById('drag-overlay')) { - return - } - - const overlayElementTemplate = - '
' - const overlayFragment = document.createRange().createContextualFragment(overlayElementTemplate) - document.body.appendChild(overlayFragment) -} - -const removeDragOverlay = () => { - document.getElementById('drag-overlay')?.remove() -} - const isHandlingFileDrag = (event: DragEvent) => event.dataTransfer?.items && Array.from(event.dataTransfer.items).some((item) => item.kind === 'file') @@ -252,11 +238,19 @@ export const AttachedFilesButton: FunctionComponent = observer( event.preventDefault() event.stopPropagation() + switch ((event.target as HTMLElement).id) { + case PopoverTabs.AllFiles: + setCurrentTab(PopoverTabs.AllFiles) + break + case PopoverTabs.AttachedFiles: + setCurrentTab(PopoverTabs.AttachedFiles) + break + } + dragCounter.current = dragCounter.current + 1 if (event.dataTransfer?.items.length) { setIsDraggingFiles(true) - createDragOverlay() if (!open) { toggleAttachedFilesMenu().catch(console.error) } @@ -279,8 +273,6 @@ export const AttachedFilesButton: FunctionComponent = observer( return } - removeDragOverlay() - setIsDraggingFiles(false) } @@ -294,7 +286,6 @@ export const AttachedFilesButton: FunctionComponent = observer( event.stopPropagation() setIsDraggingFiles(false) - removeDragOverlay() if (event.dataTransfer?.items.length) { Array.from(event.dataTransfer.items).forEach(async (item) => { diff --git a/app/assets/javascripts/Components/AttachedFilesPopover/AttachedFilesPopover.tsx b/app/assets/javascripts/Components/AttachedFilesPopover/AttachedFilesPopover.tsx index 15221a5ad21..f3e471b0712 100644 --- a/app/assets/javascripts/Components/AttachedFilesPopover/AttachedFilesPopover.tsx +++ b/app/assets/javascripts/Components/AttachedFilesPopover/AttachedFilesPopover.tsx @@ -10,11 +10,7 @@ import { Button } from '@/Components/Button/Button' import { Icon } from '@/Components/Icon' import { PopoverFileItem } from './PopoverFileItem' import { PopoverFileItemAction, PopoverFileItemActionType } from './PopoverFileItemAction' - -export enum PopoverTabs { - AttachedFiles, - AllFiles, -} +import { PopoverTabs } from './PopoverTabs' type Props = { application: WebApplication @@ -75,6 +71,7 @@ export const AttachedFilesPopover: FunctionComponent = observer( >