Skip to content

Commit febae53

Browse files
committed
feat(ui): Tweak GlobalDrawer useEffect for closing
`currentDrawerConfig` undefined means the drawer should already be closed, no need to call `closeDrawer` (right?). We still want to maintain the defaut close behavior if `shouldCloseOnLocation` is not defined.
1 parent 1494b9e commit febae53

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

static/app/components/globalDrawer/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,11 @@ export function GlobalDrawer({children}: any) {
130130
useLayoutEffect(
131131
() => {
132132
// Defaults to closing the drawer when the location changes
133-
if (currentDrawerConfig?.options.shouldCloseOnLocationChange?.(location) ?? true) {
133+
if (
134+
// Drawer should be closed already if `currentDrawerConfig` is undefined
135+
currentDrawerConfig !== undefined &&
136+
(currentDrawerConfig?.options.shouldCloseOnLocationChange?.(location) ?? true)
137+
) {
134138
// Call `closeDrawer` without invoking `onClose` callback, since those callbacks often update the URL
135139
closeDrawer();
136140
}

0 commit comments

Comments
 (0)