RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
fix(ui): ignore outside clicks right after dialog opens (#20270)
chanxf6483a1616e7
diff --git a/web/src/components/ui/dialog.tsx b/web/src/components/ui/dialog.tsxindex 04e8085f5e..fde8ccd00c 100644--- a/web/src/components/ui/dialog.tsx+++ b/web/src/components/ui/dialog.tsx@@ -32,41 +32,56 @@ DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;const DialogContent = React.forwardRef<React.ElementRef<typeof DialogPrimitive.Content>,React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>->(({ className, children, ...props }, ref) => (- <DialogPortal>- <DialogOverlay />- <DialogPrimitive.Content- ref={ref}- className={cn(- 'outline-none outline-0 fixed left-[50%] top-[50%] rounded-lg z-50 grid w-full max-w-xl translate-x-[-50%] translate-y-[-50%]',- // TODO: to keep scrollbar perfectly aligned to header bottom and/or footer top,- // 'gap-4' should be removed, then bring your own body container with padding-y instead.- 'gap-4',- 'border-0.5 border-border-button bg-bg-base p-6 shadow-lg duration-200 sm:rounded-lg',- 'data-[state=open]:animate-in data-[state=closed]:animate-out',- 'data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',- 'data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95',- 'data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%]',- 'data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]',- className,- )}- {...props}- >- {children}- <DialogPrimitive.Close- className="+>(({ className, children, onPointerDownOutside, ...props }, ref) => {+ const mountedAtRef = React.useRef(Date.now());++ return (+ <DialogPortal>+ <DialogOverlay />+ <DialogPrimitive.Content+ ref={ref}+ onPointerDownOutside={(e) => {+ // Ignore outside presses within the first moments after the dialog+ // opens: they come from the second press of a double-click on the+ // trigger/menu item. Letting it through would dismiss the dialog+ // instantly and can leave react-remove-scroll's pointer lock stuck+ // (pointer-events: none on body, freezing the page).+ if (Date.now() - mountedAtRef.current < 200) {+ e.preventDefault();+ }+ onPointerDownOutside?.(e);+ }}+ className={cn(+ 'outline-none outline-0 fixed left-[50%] top-[50%] rounded-lg z-50 grid w-full max-w-xl translate-x-[-50%] translate-y-[-50%]',+ // TODO: to keep scrollbar perfectly aligned to header bottom and/or footer top,+ // 'gap-4' should be removed, then bring your own body container with padding-y instead.+ 'gap-4',+ 'border-0.5 border-border-button bg-bg-base p-6 shadow-lg duration-200 sm:rounded-lg',+ 'data-[state=open]:animate-in data-[state=closed]:animate-out',+ 'data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',+ 'data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95',+ 'data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%]',+ 'data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]',+ className,+ )}+ {...props}+ >+ {children}+ <DialogPrimitive.Close+ className="absolute right-4 top-4 p-2 rounded-sm opacity-70 outline-none text-text-secondary transition-colorshover:bg-border-button hover:text-text-primaryfocus-visible:bg-border-button focus-visible:text-text-primarydisabled:pointer-events-none data-[state=open]:bg-bg-accent data-[state=open]:text-muted-foreground"- >- <X className="h-4 w-4" />- <span className="sr-only">Close</span>- </DialogPrimitive.Close>- </DialogPrimitive.Content>- </DialogPortal>-));+ >+ <X className="h-4 w-4" />+ <span className="sr-only">Close</span>+ </DialogPrimitive.Close>+ </DialogPrimitive.Content>+ </DialogPortal>+ );+});DialogContent.displayName = DialogPrimitive.Content.displayName;const DialogHeader = ({