Skip to content

Commit 9e453da

Browse files
author
Brian Vaughn
committed
Clicked to background overlay dismiss
1 parent 404c66c commit 9e453da

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

Diff for: packages/react-error-overlay/src/components/overlay.js

+5
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ function createOverlay(
3232
const frameSettings: FrameSetting[] = frames.map(() => ({ compiled: false }));
3333
// Create overlay
3434
const overlay = document.createElement('div');
35+
overlay.addEventListener('click', function(event: Event) {
36+
// Clicks to background layer dismiss the popup
37+
// Prevent clicks within the panel from accidentally dismissing
38+
event.stopPropagation();
39+
});
3540
applyStyles(overlay, overlayStyle);
3641
overlay.appendChild(createClose(document, closeCallback));
3742

Diff for: packages/react-error-overlay/src/overlay.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,10 @@ function render(name: ?string, message: string, resolvedFrames: StackFrame[]) {
7979
};
8080
}
8181
if (document.body != null) {
82-
document.body.style.margin = 0;
82+
document.body.style.margin = '0';
8383
document.body.appendChild(overlay);
84+
// Clicks to background overlay should dismiss error popup
85+
(document.body: any).addEventListener('click', unmount);
8486
}
8587
additionalReference = additional;
8688
};

0 commit comments

Comments
 (0)