Skip to content

Commit a330711

Browse files
authored
Merge pull request #540 from mfts/fix/refresh
fix(radix-ui): reset pointer-events to unfreeze UI
2 parents f56f135 + 77f9de0 commit a330711

5 files changed

Lines changed: 44 additions & 24 deletions

File tree

components/datarooms/dataroom-document-card.tsx

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ type DocumentsCardProps = {
3636
teamInfo: TeamContextType | null;
3737
};
3838
export default function DataroomDocumentCard({
39-
document,
39+
document: dataroomDocument,
4040
teamInfo,
4141
}: DocumentsCardProps) {
4242
const { theme, systemTheme } = useTheme();
@@ -49,16 +49,25 @@ export default function DataroomDocumentCard({
4949
const [moveFolderOpen, setMoveFolderOpen] = useState<boolean>(false);
5050
const dropdownRef = useRef<HTMLDivElement | null>(null);
5151

52+
// https://github.com/radix-ui/primitives/issues/1241#issuecomment-1888232392
53+
useEffect(() => {
54+
if (!moveFolderOpen) {
55+
setTimeout(() => {
56+
document.body.style.pointerEvents = "";
57+
});
58+
}
59+
}, [moveFolderOpen]);
60+
5261
return (
5362
<>
5463
<li className="group/row relative flex items-center justify-between rounded-lg border-0 p-3 ring-1 ring-gray-200 transition-all hover:bg-secondary hover:ring-gray-300 dark:bg-secondary dark:ring-gray-700 hover:dark:ring-gray-500 sm:p-4">
5564
<div className="flex min-w-0 shrink items-center space-x-2 sm:space-x-4">
5665
<div className="mx-0.5 flex w-8 items-center justify-center text-center sm:mx-1">
57-
{document.document.type === "notion" ? (
66+
{dataroomDocument.document.type === "notion" ? (
5867
<NotionIcon className="h-8 w-8" />
5968
) : (
6069
<Image
61-
src={`/_icons/${document.document.type}${isLight ? "-light" : ""}.svg`}
70+
src={`/_icons/${dataroomDocument.document.type}${isLight ? "-light" : ""}.svg`}
6271
alt="File icon"
6372
width={50}
6473
height={50}
@@ -70,20 +79,20 @@ export default function DataroomDocumentCard({
7079
<div className="flex items-center">
7180
<h2 className="min-w-0 max-w-[150px] truncate text-sm font-semibold leading-6 text-foreground sm:max-w-md">
7281
<Link
73-
href={`/documents/${document.document.id}`}
82+
href={`/documents/${dataroomDocument.document.id}`}
7483
className="w-full truncate"
7584
>
76-
<span>{document.document.name}</span>
85+
<span>{dataroomDocument.document.name}</span>
7786
<span className="absolute inset-0" />
7887
</Link>
7988
</h2>
8089
</div>
8190
<div className="mt-1 flex items-center space-x-1 text-xs leading-5 text-muted-foreground">
82-
<p className="truncate">{timeAgo(document.createdAt)}</p>
83-
{document.document._count.versions > 1 ? (
91+
<p className="truncate">{timeAgo(dataroomDocument.createdAt)}</p>
92+
{dataroomDocument.document._count.versions > 1 ? (
8493
<>
8594
<p></p>
86-
<p className="truncate">{`${document.document._count.versions} Versions`}</p>
95+
<p className="truncate">{`${dataroomDocument.document._count.versions} Versions`}</p>
8796
</>
8897
) : null}
8998
</div>
@@ -95,12 +104,12 @@ export default function DataroomDocumentCard({
95104
onClick={(e) => {
96105
e.stopPropagation();
97106
}}
98-
href={`/documents/${document.document.id}`}
107+
href={`/documents/${dataroomDocument.document.id}`}
99108
className="z-10 flex items-center space-x-1 rounded-md bg-gray-200 px-1.5 py-0.5 transition-all duration-75 hover:scale-105 active:scale-100 dark:bg-gray-700 sm:px-2"
100109
>
101110
<BarChart className="h-3 w-3 text-muted-foreground sm:h-4 sm:w-4" />
102111
<p className="whitespace-nowrap text-xs text-muted-foreground sm:text-sm">
103-
{nFormatter(document.document._count.views)}
112+
{nFormatter(dataroomDocument.document._count.views)}
104113
<span className="ml-1 hidden sm:inline-block">views</span>
105114
</p>
106115
</Link>
@@ -144,9 +153,9 @@ export default function DataroomDocumentCard({
144153
<MoveToDataroomFolderModal
145154
open={moveFolderOpen}
146155
setOpen={setMoveFolderOpen}
147-
dataroomId={document.dataroomId}
148-
documentId={document.id}
149-
documentName={document.document.name}
156+
dataroomId={dataroomDocument.dataroomId}
157+
documentId={dataroomDocument.id}
158+
documentName={dataroomDocument.document.name}
150159
/>
151160
) : null}
152161
</>

components/documents/document-card.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,15 @@ export default function DocumentsCard({
6868
);
6969
}
7070

71+
// https://github.com/radix-ui/primitives/issues/1241#issuecomment-1888232392
72+
useEffect(() => {
73+
if (!moveFolderOpen || !addDataroomOpen) {
74+
setTimeout(() => {
75+
document.body.style.pointerEvents = "";
76+
});
77+
}
78+
}, [moveFolderOpen, addDataroomOpen]);
79+
7180
useEffect(() => {
7281
function handleClickOutside(event: { target: any }) {
7382
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {

components/documents/folder-card.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,15 @@ export default function FolderCard({
6363
};
6464
}, []);
6565

66+
// https://github.com/radix-ui/primitives/issues/1241#issuecomment-1888232392
67+
useEffect(() => {
68+
if (!openFolder) {
69+
setTimeout(() => {
70+
document.body.style.pointerEvents = "";
71+
});
72+
}
73+
}, [openFolder]);
74+
6675
const handleButtonClick = (event: any, documentId: string) => {
6776
event.stopPropagation();
6877
event.preventDefault();
@@ -160,7 +169,7 @@ export default function FolderCard({
160169
<li className="group/row relative flex items-center justify-between rounded-lg border-0 p-3 ring-1 ring-gray-400 transition-all hover:bg-secondary hover:ring-gray-500 dark:bg-secondary dark:ring-gray-500 hover:dark:ring-gray-400 sm:p-4">
161170
<div className="flex min-w-0 shrink items-center space-x-2 sm:space-x-4">
162171
<div className="mx-0.5 flex w-8 items-center justify-center text-center sm:mx-1">
163-
<FolderIcon className="h-8 w-8 " strokeWidth={1} />
172+
<FolderIcon className="h-8 w-8" strokeWidth={1} />
164173
</div>
165174

166175
<div className="flex-col">

components/documents/move-folder-modal.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ export function MoveToFolderModal({
9696
<DialogContent className="sm:max-w-[425px]">
9797
<DialogHeader className="text-start">
9898
<DialogTitle>
99-
Move <span className="font-bold">{documentName}</span>
99+
Move
100+
<div className="w-[376px] truncate font-bold">{documentName}</div>
100101
</DialogTitle>
101102
<DialogDescription>Move your document to a folder.</DialogDescription>
102103
</DialogHeader>

components/folders/edit-folder-modal.tsx

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
import { useRouter } from "next/router";
2-
3-
import { useState } from "react";
1+
import { useEffect, useState } from "react";
42

53
import { useTeam } from "@/context/team-context";
6-
import { Folder } from "@prisma/client";
74
import { toast } from "sonner";
85
import { mutate } from "swr";
96

@@ -20,11 +17,6 @@ import {
2017
import { Input } from "@/components/ui/input";
2118
import { Label } from "@/components/ui/label";
2219

23-
import { useAnalytics } from "@/lib/analytics";
24-
import { usePlan } from "@/lib/swr/use-billing";
25-
26-
import { UpgradePlanModal } from "../billing/upgrade-plan-modal";
27-
2820
export function EditFolderModal({
2921
open,
3022
setOpen,

0 commit comments

Comments
 (0)