Skip to content

Commit

Permalink
Clicked to background overlay dismiss
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Vaughn committed May 17, 2017
1 parent 404c66c commit 9e453da
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions packages/react-error-overlay/src/components/overlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ function createOverlay(
const frameSettings: FrameSetting[] = frames.map(() => ({ compiled: false }));
// Create overlay
const overlay = document.createElement('div');
overlay.addEventListener('click', function(event: Event) {
// Clicks to background layer dismiss the popup
// Prevent clicks within the panel from accidentally dismissing
event.stopPropagation();
});
applyStyles(overlay, overlayStyle);
overlay.appendChild(createClose(document, closeCallback));

Expand Down
4 changes: 3 additions & 1 deletion packages/react-error-overlay/src/overlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,10 @@ function render(name: ?string, message: string, resolvedFrames: StackFrame[]) {
};
}
if (document.body != null) {
document.body.style.margin = 0;
document.body.style.margin = '0';
document.body.appendChild(overlay);
// Clicks to background overlay should dismiss error popup
(document.body: any).addEventListener('click', unmount);
}
additionalReference = additional;
};
Expand Down

0 comments on commit 9e453da

Please sign in to comment.