Skip to content

Commit d0b21b6

Browse files
committed
properly close when click outside
1 parent 019f6b3 commit d0b21b6

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

packages/next/src/next-devtools/dev-overlay/components/devtools-panel/devtools-panel.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { OverlayDispatch, OverlayState, Corners } from '../../shared'
33
import { useState } from 'react'
44

55
import { Dialog, DialogContent, DialogHeader, DialogBody } from '../dialog'
6-
import { Overlay } from '../overlay/overlay'
6+
import { Overlay, OverlayBackdrop } from '../overlay'
77
import {
88
ACTION_DEVTOOLS_PANEL_CLOSE,
99
STORAGE_KEY_DEVTOOLS_PANEL_POSITION,
@@ -48,6 +48,8 @@ export function DevToolsPanel({
4848
[horizontal === 'left' ? 'right' : 'left']: 'auto',
4949
}}
5050
>
51+
{/* TODO: Investigate why onClose on Dialog doesn't close when clicked outside. */}
52+
<OverlayBackdrop data-nextjs-devtools-panel-overlay-backdrop onClick={onClose} />
5153
<Draggable
5254
padding={INDICATOR_PADDING}
5355
onDragStart={() => {}}
@@ -81,6 +83,11 @@ export const DEVTOOLS_PANEL_STYLES = css`
8183
/* top: 10vh; */
8284
}
8385
86+
[data-nextjs-devtools-panel-overlay-backdrop] {
87+
/* TODO: Blur on fullscreen mode. */
88+
opacity: 0;
89+
}
90+
8491
[data-nextjs-devtools-panel-dialog] {
8592
-webkit-font-smoothing: antialiased;
8693
display: flex;

packages/next/src/next-devtools/dev-overlay/dev-overlay.stories.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import imgApp from './app.png'
77
import { useReducer } from 'react'
88
import { DevOverlay } from './dev-overlay'
99
import {
10+
ACTION_DEVTOOLS_PANEL_CLOSE,
1011
ACTION_DEVTOOLS_PANEL_TOGGLE,
1112
ACTION_ERROR_OVERLAY_CLOSE,
1213
ACTION_ERROR_OVERLAY_OPEN,
@@ -114,6 +115,9 @@ function useOverlayReducer() {
114115
case ACTION_DEVTOOLS_PANEL_TOGGLE: {
115116
return { ...state, isDevToolsPanelOpen: !state.isDevToolsPanelOpen }
116117
}
118+
case ACTION_DEVTOOLS_PANEL_CLOSE: {
119+
return { ...state, isDevToolsPanelOpen: false }
120+
}
117121
default: {
118122
return state
119123
}

0 commit comments

Comments
 (0)