Skip to content

Commit 2c57888

Browse files
authored
[dev-overlay]: allow disabled state to be dismissable (#76572)
When you disable the dev indicator, either with `devIndicators: false` or clicking the hide button, we still show a minimized version so you can open up the error overlay. That version should also be dismissible within the current browser session. https://github.com/user-attachments/assets/bbf114c1-2c73-4051-8fbc-dbd93acb7f64
1 parent c919f09 commit 2c57888

File tree

1 file changed

+15
-9
lines changed
  • packages/next/src/client/components/react-dev-overlay/ui/components/errors/dev-tools-indicator

1 file changed

+15
-9
lines changed

packages/next/src/client/components/react-dev-overlay/ui/components/errors/dev-tools-indicator/next-logo.tsx

+15-9
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ export const NextLogo = forwardRef(function NextLogo(
7777
shouldSkip: (count) => count === 0,
7878
animationDuration: SHORT_DURATION_MS,
7979
})
80+
const [dismissed, setDismissed] = useState(false)
8081

8182
const triggerRef = useRef<HTMLButtonElement | null>(null)
8283
const ref = useRef<HTMLDivElement | null>(null)
@@ -90,15 +91,18 @@ export const NextLogo = forwardRef(function NextLogo(
9091
setIsErrorExpanded(hasError)
9192
}, [hasError])
9293

94+
const isExpanded = isErrorExpanded || disabled
95+
9396
return (
9497
<div
9598
data-next-badge-root
9699
style={
97100
{
98101
'--size': SIZE,
99102
'--duration-short': `${SHORT_DURATION_MS}ms`,
100-
// if the indicator is disabled and there are no errors, hide the badge
101-
display: disabled && !hasError ? 'none' : 'block',
103+
// if the indicator is disabled, hide the badge
104+
// also allow the "disabled" state be dismissed, as long as there are no build errors
105+
display: disabled && (!hasError || dismissed) ? 'none' : 'block',
102106
} as React.CSSProperties
103107
}
104108
>
@@ -226,9 +230,7 @@ export const NextLogo = forwardRef(function NextLogo(
226230
gap: 2px;
227231
align-items: center;
228232
padding-left: 8px;
229-
padding-right: ${disabled || isBuildError
230-
? '8px'
231-
: 'calc(2px * 2)'};
233+
padding-right: ${isBuildError ? '8px' : 'calc(2px * 2)'};
232234
height: var(--size-32);
233235
margin: 0 2px;
234236
border-radius: var(--rounded-full);
@@ -422,7 +424,7 @@ export const NextLogo = forwardRef(function NextLogo(
422424
<div
423425
data-next-badge
424426
data-error={hasError}
425-
data-error-expanded={isErrorExpanded}
427+
data-error-expanded={isExpanded}
426428
data-animate={newErrorDetected}
427429
style={{
428430
width: hasError && width > SIZE_PX ? width : SIZE,
@@ -441,7 +443,7 @@ export const NextLogo = forwardRef(function NextLogo(
441443
<NextMark isLoading={isLoading} isDevBuilding={isDevBuilding} />
442444
</button>
443445
)}
444-
{isErrorExpanded && (
446+
{isExpanded && (
445447
<div data-issues>
446448
<button
447449
data-issues-open
@@ -470,12 +472,16 @@ export const NextLogo = forwardRef(function NextLogo(
470472
)}
471473
</div>
472474
</button>
473-
{!disabled && !isBuildError && (
475+
{!isBuildError && (
474476
<button
475477
data-issues-collapse
476478
aria-label="Collapse issues badge"
477479
onClick={() => {
478-
setIsErrorExpanded(false)
480+
if (disabled) {
481+
setDismissed(true)
482+
} else {
483+
setIsErrorExpanded(false)
484+
}
479485
// Move focus to the trigger to prevent having it stuck on this element
480486
triggerRef.current?.focus()
481487
}}

0 commit comments

Comments
 (0)