Skip to content

Commit

Permalink
fix: Fix Dialog closing on Firefox when the window loses focus and …
Browse files Browse the repository at this point in the history
…get focused again (#620)

Closes #619
  • Loading branch information
tom-sherman committed Apr 15, 2020
1 parent db71535 commit 7c3119d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/reakit/src/Dialog/__utils/useHideOnClickOutside.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ export function useHideOnClickOutside(
// triggered the mousedown event. This prevents the dialog from closing
// by dragging the cursor (for example, selecting some text inside the
// dialog and releasing the mouse outside of it).
if (mouseDownRef.current === event.target && options.hide) {
options.hide();
if (mouseDownRef.current === event.target) {
options.hide?.();
}
},
options.visible && options.hideOnClickOutside
Expand All @@ -59,7 +59,12 @@ export function useHideOnClickOutside(
disclosuresRef,
nestedDialogs,
"focus",
options.hide,
(event) => {
// Fix for https://github.com/reakit/reakit/issues/619
if (event.target !== getDocument(dialogRef.current)) {
options.hide?.();
}
},
options.visible && options.hideOnClickOutside
);
}

0 comments on commit 7c3119d

Please sign in to comment.