Skip to content

Commit 32498af

Browse files
committed
properly close when click outside
1 parent e504dbc commit 32498af

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 { Suspense, useRef, 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 { useFocusTrap } from '../errors/dev-tools-indicator/utils'
88
import { useDelayedRender } from '../../hooks/use-delayed-render'
99
import {
@@ -61,6 +61,8 @@ export function DevToolsPanel({
6161
[horizontal === 'left' ? 'right' : 'left']: 'auto',
6262
}}
6363
>
64+
{/* TODO: Investigate why onClose on Dialog doesn't close when clicked outside. */}
65+
<OverlayBackdrop data-nextjs-devtools-panel-backdrop onClick={onClose} />
6466
<Draggable
6567
padding={INDICATOR_PADDING}
6668
onDragStart={() => {}}
@@ -96,6 +98,11 @@ export const DEVTOOLS_PANEL_STYLES = css`
9698
/* top: 10vh; */
9799
}
98100
101+
[data-nextjs-devtools-panel-backdrop] {
102+
/* TODO: Blur on fullscreen mode. */
103+
opacity: 0;
104+
}
105+
99106
[data-nextjs-devtools-panel-container] {
100107
-webkit-font-smoothing: antialiased;
101108
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)