From 8d2f2992104fb39a0f08e5c45f998bf404e69910 Mon Sep 17 00:00:00 2001 From: Micrufun Date: Sun, 18 Dec 2022 21:58:39 +0330 Subject: [PATCH 1/2] Check if browser supplies event path information --- .../components/_shared/popup/PopupContent.jsx | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/frontend/src/static/js/components/_shared/popup/PopupContent.jsx b/frontend/src/static/js/components/_shared/popup/PopupContent.jsx index d341bde..10d70dd 100644 --- a/frontend/src/static/js/components/_shared/popup/PopupContent.jsx +++ b/frontend/src/static/js/components/_shared/popup/PopupContent.jsx @@ -16,8 +16,23 @@ export function PopupContent(props) { const domElem = findDOMNode(wrapperRef.current); - if (-1 === ev.path.indexOf(domElem)) { - hide(); + // To avoid this error on Firefox: + // Uncaught TypeError: e.path is undefined + // And this error on Chromium: + // Uncaught TypeError: Cannot read properties of undefined (reading 'indexOf') + // + // https://stackoverflow.com/a/39245638/3405291 + // + // It allows for both the old way and the new, standard way. + // So will do its best cross-browser. + var path = ev.path || (ev.composedPath && ev.composedPath()); + if (path) { + if (-1 === path.indexOf(domElem)) { + hide(); + } + } else { + Console.log("This browser doesn't supply event path information") + // TODO: Should call hide()? } }, []); From 425a9dc59583226e7512817ad8ee577f61018faa Mon Sep 17 00:00:00 2001 From: Micrufun Date: Thu, 15 Jun 2023 10:07:20 +0330 Subject: [PATCH 2/2] Fix typo --- .../src/static/js/components/_shared/popup/PopupContent.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/static/js/components/_shared/popup/PopupContent.jsx b/frontend/src/static/js/components/_shared/popup/PopupContent.jsx index 10d70dd..c9c2460 100644 --- a/frontend/src/static/js/components/_shared/popup/PopupContent.jsx +++ b/frontend/src/static/js/components/_shared/popup/PopupContent.jsx @@ -31,7 +31,7 @@ export function PopupContent(props) { hide(); } } else { - Console.log("This browser doesn't supply event path information") + console.log("This browser doesn't supply event path information") // TODO: Should call hide()? } }, []);