Skip to content

Commit 3913642

Browse files
committed
fix: check if email window is open before displaying warnings
The offset parent will be set to null when the email message is minimized which might happen when composing a new email depending on how wide the browser window is
1 parent e28c5a3 commit 3913642

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/components/JustNotSorry.js

+3-7
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,13 @@ const JustNotSorry = ({ onEvents, phrases }) => {
4848
observer,
4949
]);
5050

51-
if (email.current != null && warnings.length > 0) {
51+
const isEmailOpen = () => email.current && email.current.offsetParent;
52+
53+
if (isEmailOpen() && warnings.length > 0) {
5254
const currentEmail = email.current;
5355
const parentRect = currentEmail.offsetParent.getBoundingClientRect();
5456
const warningComponents = warnings.map((warning, i) => {
5557
let key = i;
56-
57-
if (currentEmail.offsetTop && currentEmail.offsetLeft) {
58-
key = `${currentEmail.offsetTop + warning.startOffset}x${
59-
currentEmail.offsetLeft + warning.endOffset
60-
}`;
61-
}
6258
if (warning?.startContainer?.parentElement) {
6359
const { offsetTop, offsetLeft } = warning.startContainer.parentElement;
6460
key = `${offsetTop + warning.startOffset}x${

0 commit comments

Comments
 (0)