Skip to content

Commit 07587c9

Browse files
committed
Make "N errors on the page" visible again
1 parent f8a2a5e commit 07587c9

File tree

3 files changed

+23
-22
lines changed

3 files changed

+23
-22
lines changed

packages/react-error-overlay/src/components/additional.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,14 @@ function updateAdditional(
1616
additionalReference.removeChild(additionalReference.lastChild);
1717
}
1818

19-
let text = ' ';
2019
if (totalErrors <= 1) {
21-
additionalReference.appendChild(document.createTextNode(text));
2220
return;
2321
}
24-
text = `Errors ${currentError} of ${totalErrors}`;
22+
2523
const span = document.createElement('span');
26-
span.appendChild(document.createTextNode(text));
2724
const group = document.createElement('span');
2825
applyStyles(group, groupStyle);
26+
2927
const left = document.createElement('button');
3028
applyStyles(left, groupElemLeft);
3129
left.addEventListener('click', function(e: MouseEvent) {
@@ -34,6 +32,7 @@ function updateAdditional(
3432
});
3533
left.appendChild(document.createTextNode('←'));
3634
enableTabClick(left);
35+
3736
const right = document.createElement('button');
3837
applyStyles(right, groupElemRight);
3938
right.addEventListener('click', function(e: MouseEvent) {
@@ -42,9 +41,14 @@ function updateAdditional(
4241
});
4342
right.appendChild(document.createTextNode('→'));
4443
enableTabClick(right);
44+
4545
group.appendChild(left);
4646
group.appendChild(right);
4747
span.appendChild(group);
48+
49+
const text = `${currentError} of ${totalErrors} errors on the page`;
50+
span.appendChild(document.createTextNode(text));
51+
4852
additionalReference.appendChild(span);
4953
}
5054

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

+12-12
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,6 @@ function createOverlay(
4040
overlay.appendChild(container);
4141
container.appendChild(createClose(document, closeCallback));
4242

43-
// Create additional
44-
const additional = document.createElement('div');
45-
applyStyles(additional, additionalStyle);
46-
container.appendChild(additional);
47-
updateAdditional(
48-
document,
49-
additional,
50-
currentError,
51-
totalErrors,
52-
switchCallback
53-
);
54-
5543
// Create header
5644
const header = document.createElement('div');
5745
applyStyles(header, headerStyle);
@@ -76,6 +64,18 @@ function createOverlay(
7664
header.appendChild(document.createTextNode(finalMessage));
7765
container.appendChild(header);
7866

67+
// Create "Errors X of Y" in case of multiple errors
68+
const additional = document.createElement('div');
69+
applyStyles(additional, additionalStyle);
70+
updateAdditional(
71+
document,
72+
additional,
73+
currentError,
74+
totalErrors,
75+
switchCallback
76+
);
77+
container.appendChild(additional);
78+
7979
// Create trace
8080
container.appendChild(
8181
createFrames(document, frames, frameSettings, contextSize, name)

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

+3-6
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,7 @@ const closeButtonStyle = {
6464
top: 0,
6565
};
6666

67-
const additionalStyle = {
68-
'margin-bottom': '1.5em',
69-
'margin-top': '-4em',
70-
};
67+
const additionalStyle = {};
7168

7269
const headerStyle = {
7370
'font-size': '2em',
@@ -141,7 +138,7 @@ const hiddenStyle = {
141138
};
142139

143140
const groupStyle = {
144-
'margin-left': '1em',
141+
'margin-right': '1em',
145142
};
146143

147144
const _groupElemStyle = {
@@ -163,7 +160,7 @@ const groupElemLeft = Object.assign({}, _groupElemStyle, {
163160
const groupElemRight = Object.assign({}, _groupElemStyle, {
164161
'border-top-left-radius': '0px',
165162
'border-bottom-left-radius': '0px',
166-
'margin-left': '-1px',
163+
'margin-right': '-1px',
167164
});
168165

169166
const footerStyle = {

0 commit comments

Comments
 (0)