Unverified Commit 6f0225a0 authored by Zack Tanner's avatar Zack Tanner Committed by GitHub

[devtools]: default to issues tab when error overlay is programmatically toggled (#81091)

When there's a build error and we toggle the error overlay on page load,
we should ensure that the issues tab is used rather than the one stored
in session storage, to avoid the case where we bring up the modal
intending to show the user an error but instead show the settings page.

Drive-by refactor: lifted storage variable to the other places where
they're defined
Closes NEXT-4596
parent f9a7d73a
......@@ -15,6 +15,7 @@ import {
STORAGE_KEY_SCALE,
STORAGE_KEY_POSITION,
ACTION_ERROR_OVERLAY_CLOSE,
STORAGE_KEY_ACTIVE_TAB,
} from '../../shared'
import { css } from '../../utils/css'
import { OverlayBackdrop } from '../overlay'
......@@ -26,8 +27,6 @@ import { MinimizeIcon } from '../../icons/minimize'
export type DevToolsPanelTabType = 'issues' | 'route' | 'settings'
const STORAGE_KEY_ACTIVE_TAB = 'nextjs-devtools-active-tab'
function useSessionState<T extends string>(
key: string,
initialValue: T
......@@ -78,6 +77,9 @@ export function DevToolsPanel({
if (state.isErrorOverlayOpen !== prevIsErrorOverlayOpen) {
if (state.isErrorOverlayOpen) {
setIsFullscreen(true)
// We should always show the issues tab initially if we're
// programmatically opening the panel to highlight errors.
setActiveTab('issues')
}
setPrevIsErrorOverlayOpen(state.isErrorOverlayOpen)
}
......
......@@ -85,6 +85,7 @@ export const ACTION_RESTART_SERVER_BUTTON = 'restart-server-button'
export const STORAGE_KEY_THEME = '__nextjs-dev-tools-theme'
export const STORAGE_KEY_POSITION = '__nextjs-dev-tools-position'
export const STORAGE_KEY_SCALE = '__nextjs-dev-tools-scale'
export const STORAGE_KEY_ACTIVE_TAB = '__nextjs-devtools-active-tab'
export const ACTION_DEVTOOL_UPDATE_ROUTE_STATE =
'segment-explorer-update-route-state'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment