Skip to content

Commit 53bc7fa

Browse files
gaearonromaindso
authored andcommitted
Improve interaction between compile and runtime overlays (facebook#2219)
1 parent 0e5b5e8 commit 53bc7fa

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

packages/react-dev-utils/webpackHotDevClient.js

+9-4
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function createOverlayIframe(onIframeLoad) {
3838
iframe.style.width = '100vw';
3939
iframe.style.height = '100vh';
4040
iframe.style.border = 'none';
41-
iframe.style.zIndex = 9999999999;
41+
iframe.style.zIndex = 2147483647;
4242
iframe.onload = onIframeLoad;
4343
return iframe;
4444
}
@@ -192,22 +192,24 @@ function clearOutdatedErrors() {
192192
// Successful compilation.
193193
function handleSuccess() {
194194
clearOutdatedErrors();
195-
destroyErrorOverlay();
196195

197196
var isHotUpdate = !isFirstCompilation;
198197
isFirstCompilation = false;
199198
hasCompileErrors = false;
200199

201200
// Attempt to apply hot updates or reload.
202201
if (isHotUpdate) {
203-
tryApplyUpdates();
202+
tryApplyUpdates(function onHotUpdateSuccess() {
203+
// Only destroy it when we're sure it's a hot update.
204+
// Otherwise it would flicker right before the reload.
205+
destroyErrorOverlay();
206+
});
204207
}
205208
}
206209

207210
// Compilation with warnings (e.g. ESLint).
208211
function handleWarnings(warnings) {
209212
clearOutdatedErrors();
210-
destroyErrorOverlay();
211213

212214
var isHotUpdate = !isFirstCompilation;
213215
isFirstCompilation = false;
@@ -231,6 +233,9 @@ function handleWarnings(warnings) {
231233
// Only print warnings if we aren't refreshing the page.
232234
// Otherwise they'll disappear right away anyway.
233235
printWarnings();
236+
// Only destroy it when we're sure it's a hot update.
237+
// Otherwise it would flicker right before the reload.
238+
destroyErrorOverlay();
234239
});
235240
} else {
236241
// Print initial warnings immediately.

packages/react-error-overlay/src/styles.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const iframeStyle = {
1515
width: '100%',
1616
height: '100%',
1717
border: 'none',
18-
'z-index': 1337,
18+
'z-index': 2147483647 - 1, // below the compile error overlay
1919
};
2020

2121
const overlayStyle = {

0 commit comments

Comments
 (0)