Skip to content

Commit c87aecd

Browse files
committed
add open close dispatch action
1 parent b735922 commit c87aecd

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ import {
1212
import {
1313
ACTION_DEVTOOLS_PANEL_TOGGLE,
1414
ACTION_ERROR_OVERLAY_TOGGLE,
15+
ACTION_ERROR_OVERLAY_CLOSE,
1516
STORAGE_KEY_POSITION,
17+
ACTION_DEVTOOLS_PANEL_CLOSE,
1618
} from '../../shared'
1719
import { getInitialPosition } from '../errors/dev-tools-indicator/dev-tools-info/preferences'
1820
import { Draggable } from '../errors/dev-tools-indicator/draggable'
@@ -38,10 +40,12 @@ export function DevToolsIndicator({
3840
const [vertical, horizontal] = position.split('-', 2)
3941

4042
const toggleErrorOverlay = () => {
43+
dispatch({ type: ACTION_DEVTOOLS_PANEL_CLOSE })
4144
dispatch({ type: ACTION_ERROR_OVERLAY_TOGGLE })
4245
}
4346

4447
const toggleDevToolsPanel = () => {
48+
dispatch({ type: ACTION_ERROR_OVERLAY_CLOSE })
4549
dispatch({ type: ACTION_DEVTOOLS_PANEL_TOGGLE })
4650
}
4751

packages/next/src/next-devtools/dev-overlay/shared.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,18 @@ export const ACTION_UNHANDLED_ERROR = 'unhandled-error'
4343
export const ACTION_UNHANDLED_REJECTION = 'unhandled-rejection'
4444
export const ACTION_DEBUG_INFO = 'debug-info'
4545
export const ACTION_DEV_INDICATOR = 'dev-indicator'
46+
4647
export const ACTION_ERROR_OVERLAY_OPEN = 'error-overlay-open'
4748
export const ACTION_ERROR_OVERLAY_CLOSE = 'error-overlay-close'
4849
export const ACTION_ERROR_OVERLAY_TOGGLE = 'error-overlay-toggle'
50+
4951
export const ACTION_BUILDING_INDICATOR_SHOW = 'building-indicator-show'
5052
export const ACTION_BUILDING_INDICATOR_HIDE = 'building-indicator-hide'
5153
export const ACTION_RENDERING_INDICATOR_SHOW = 'rendering-indicator-show'
5254
export const ACTION_RENDERING_INDICATOR_HIDE = 'rendering-indicator-hide'
55+
56+
export const ACTION_DEVTOOLS_PANEL_OPEN = 'dev-tools-panel-open'
57+
export const ACTION_DEVTOOLS_PANEL_CLOSE = 'dev-tools-panel-close'
5358
export const ACTION_DEVTOOLS_PANEL_TOGGLE = 'dev-tools-panel-toggle'
5459

5560
export const STORAGE_KEY_THEME = '__nextjs-dev-tools-theme'
@@ -123,6 +128,12 @@ export interface RenderingIndicatorHideAction {
123128
type: typeof ACTION_RENDERING_INDICATOR_HIDE
124129
}
125130

131+
export interface DevToolsPanelOpenAction {
132+
type: typeof ACTION_DEVTOOLS_PANEL_OPEN
133+
}
134+
export interface DevToolsPanelCloseAction {
135+
type: typeof ACTION_DEVTOOLS_PANEL_CLOSE
136+
}
126137
export interface DevToolsPanelToggleAction {
127138
type: typeof ACTION_DEVTOOLS_PANEL_TOGGLE
128139
}
@@ -145,6 +156,8 @@ export type DispatcherEvent =
145156
| BuildingIndicatorHideAction
146157
| RenderingIndicatorShowAction
147158
| RenderingIndicatorHideAction
159+
| DevToolsPanelOpenAction
160+
| DevToolsPanelCloseAction
148161
| DevToolsPanelToggleAction
149162

150163
const REACT_ERROR_STACK_BOTTOM_FRAME_REGEX =
@@ -347,6 +360,12 @@ export function useErrorOverlayReducer(
347360
case ACTION_RENDERING_INDICATOR_HIDE: {
348361
return { ...state, renderingIndicator: false }
349362
}
363+
case ACTION_DEVTOOLS_PANEL_OPEN: {
364+
return { ...state, isDevToolsPanelOpen: true }
365+
}
366+
case ACTION_DEVTOOLS_PANEL_CLOSE: {
367+
return { ...state, isDevToolsPanelOpen: false }
368+
}
350369
case ACTION_DEVTOOLS_PANEL_TOGGLE: {
351370
return { ...state, isDevToolsPanelOpen: !state.isDevToolsPanelOpen }
352371
}

0 commit comments

Comments
 (0)