Browse Source

fix(starfish): onclose gets ran when already closed (#48348)

The onclose in the sidebar got ran even when it was already closed, this
somehow caused the legends in the db module to stop working.

---------

Co-authored-by: Ash Anand <0Calories@users.noreply.github.com>
Dominik Buszowiecki 1 year ago
parent
commit
daf66b7111
1 changed files with 8 additions and 4 deletions
  1. 8 4
      static/app/views/starfish/components/detailPanel.tsx

+ 8 - 4
static/app/views/starfish/components/detailPanel.tsx

@@ -32,14 +32,18 @@ export default function Detail({children, detailKey, onClose}: DetailProps) {
 
   const panelRef = useRef<HTMLDivElement>(null);
   useOnClickOutside(panelRef, () => {
-    onClose?.();
-    setState({collapsed: true});
+    if (!state.collapsed) {
+      onClose?.();
+      setState({collapsed: true});
+    }
   });
 
   useEffect(() => {
     if (escapeKeyPressed) {
-      onClose?.();
-      setState({collapsed: true});
+      if (!state.collapsed) {
+        onClose?.();
+        setState({collapsed: true});
+      }
     }
     // eslint-disable-next-line react-hooks/exhaustive-deps
   }, [escapeKeyPressed]);