fix: Ensure attachment modal appears above Command Menu button using createPortal (#12112)
<img width="1509" alt="Screenshot 2025-05-19 at 12 50 48 AM" src="https://github.com/user-attachments/assets/fba95ecb-015a-4742-bda2-4d515d168c16" /> Closes #12092
This commit is contained in:
@ -1,5 +1,6 @@
|
|||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
import { lazy, ReactElement, Suspense, useState } from 'react';
|
import { lazy, ReactElement, Suspense, useState } from 'react';
|
||||||
|
import { createPortal } from 'react-dom';
|
||||||
|
|
||||||
import { DropZone } from '@/activities/files/components/DropZone';
|
import { DropZone } from '@/activities/files/components/DropZone';
|
||||||
import { useUploadAttachmentFile } from '@/activities/files/hooks/useUploadAttachmentFile';
|
import { useUploadAttachmentFile } from '@/activities/files/hooks/useUploadAttachmentFile';
|
||||||
@ -184,52 +185,55 @@ export const AttachmentList = ({
|
|||||||
</StyledDropZoneContainer>
|
</StyledDropZoneContainer>
|
||||||
</StyledContainer>
|
</StyledContainer>
|
||||||
)}
|
)}
|
||||||
{previewedAttachment && isAttachmentPreviewEnabled && (
|
{previewedAttachment &&
|
||||||
<StyledModal
|
isAttachmentPreviewEnabled &&
|
||||||
modalId={PREVIEW_MODAL_ID}
|
createPortal(
|
||||||
size="large"
|
<StyledModal
|
||||||
isClosable
|
modalId={PREVIEW_MODAL_ID}
|
||||||
onClose={handleClosePreview}
|
size="large"
|
||||||
>
|
isClosable
|
||||||
<StyledModalHeader>
|
onClose={handleClosePreview}
|
||||||
<StyledHeader>
|
|
||||||
<StyledModalTitle>{previewedAttachment.name}</StyledModalTitle>
|
|
||||||
<StyledButtonContainer>
|
|
||||||
<IconButton
|
|
||||||
Icon={IconDownload}
|
|
||||||
onClick={handleDownload}
|
|
||||||
size="small"
|
|
||||||
/>
|
|
||||||
<IconButton
|
|
||||||
Icon={IconX}
|
|
||||||
onClick={handleClosePreview}
|
|
||||||
size="small"
|
|
||||||
/>
|
|
||||||
</StyledButtonContainer>
|
|
||||||
</StyledHeader>
|
|
||||||
</StyledModalHeader>
|
|
||||||
<ScrollWrapper
|
|
||||||
componentInstanceId={`preview-modal-${previewedAttachment.id}`}
|
|
||||||
>
|
>
|
||||||
<StyledModalContent>
|
<StyledModalHeader>
|
||||||
<Suspense
|
<StyledHeader>
|
||||||
fallback={
|
<StyledModalTitle>{previewedAttachment.name}</StyledModalTitle>
|
||||||
<StyledLoadingContainer>
|
<StyledButtonContainer>
|
||||||
<StyledLoadingText>
|
<IconButton
|
||||||
Loading document viewer...
|
Icon={IconDownload}
|
||||||
</StyledLoadingText>
|
onClick={handleDownload}
|
||||||
</StyledLoadingContainer>
|
size="small"
|
||||||
}
|
/>
|
||||||
>
|
<IconButton
|
||||||
<DocumentViewer
|
Icon={IconX}
|
||||||
documentName={previewedAttachment.name}
|
onClick={handleClosePreview}
|
||||||
documentUrl={previewedAttachment.fullPath}
|
size="small"
|
||||||
/>
|
/>
|
||||||
</Suspense>
|
</StyledButtonContainer>
|
||||||
</StyledModalContent>
|
</StyledHeader>
|
||||||
</ScrollWrapper>
|
</StyledModalHeader>
|
||||||
</StyledModal>
|
<ScrollWrapper
|
||||||
)}
|
componentInstanceId={`preview-modal-${previewedAttachment.id}`}
|
||||||
|
>
|
||||||
|
<StyledModalContent>
|
||||||
|
<Suspense
|
||||||
|
fallback={
|
||||||
|
<StyledLoadingContainer>
|
||||||
|
<StyledLoadingText>
|
||||||
|
Loading document viewer...
|
||||||
|
</StyledLoadingText>
|
||||||
|
</StyledLoadingContainer>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<DocumentViewer
|
||||||
|
documentName={previewedAttachment.name}
|
||||||
|
documentUrl={previewedAttachment.fullPath}
|
||||||
|
/>
|
||||||
|
</Suspense>
|
||||||
|
</StyledModalContent>
|
||||||
|
</ScrollWrapper>
|
||||||
|
</StyledModal>,
|
||||||
|
document.body,
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user