Skip to content

Commit

Permalink
prevent dialog from closing on outsideclick
Browse files Browse the repository at this point in the history
  • Loading branch information
maheshj01 committed Oct 6, 2024
1 parent 7430bca commit 1f1b5c6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/app/(main)/_components/GeminiDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const GeminiDialog: React.FC<GeminiDialogProps> = ({ isOpen, onClose, onSave, ti

return (
<Modal size="md" isOpen={isOpen} onClose={onClose} isDismissable={true}>
<ModalContent>
<ModalContent className="gemini-dialog-class">
<ModalHeader className="flex flex-col mt-1">
<div className="flex">
<Image
Expand Down
3 changes: 2 additions & 1 deletion src/app/(main)/_hooks/outsideclick.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ const useClickOutside = <T extends HTMLElement>(ref: RefObject<T>, fn: () => voi
useEffect(() => {
const element = ref?.current;
function handleClickOutside(event: Event) {
if (element && !element.contains(event.target as Node | null)) {
const dialog = document.querySelector('.gemini-dialog-class');
if (element && !element.contains(event.target as Node | null) && (!dialog || !dialog.contains(event.target as Node | null))) {
fn();
}
}
Expand Down

0 comments on commit 1f1b5c6

Please sign in to comment.