Unverified Commit 2c578889 authored by Zack Tanner's avatar Zack Tanner Committed by GitHub

[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
parent c919f09a
...@@ -77,6 +77,7 @@ export const NextLogo = forwardRef(function NextLogo( ...@@ -77,6 +77,7 @@ export const NextLogo = forwardRef(function NextLogo(
shouldSkip: (count) => count === 0, shouldSkip: (count) => count === 0,
animationDuration: SHORT_DURATION_MS, animationDuration: SHORT_DURATION_MS,
}) })
const [dismissed, setDismissed] = useState(false)
const triggerRef = useRef<HTMLButtonElement | null>(null) const triggerRef = useRef<HTMLButtonElement | null>(null)
const ref = useRef<HTMLDivElement | null>(null) const ref = useRef<HTMLDivElement | null>(null)
...@@ -90,6 +91,8 @@ export const NextLogo = forwardRef(function NextLogo( ...@@ -90,6 +91,8 @@ export const NextLogo = forwardRef(function NextLogo(
setIsErrorExpanded(hasError) setIsErrorExpanded(hasError)
}, [hasError]) }, [hasError])
const isExpanded = isErrorExpanded || disabled
return ( return (
<div <div
data-next-badge-root data-next-badge-root
...@@ -97,8 +100,9 @@ export const NextLogo = forwardRef(function NextLogo( ...@@ -97,8 +100,9 @@ export const NextLogo = forwardRef(function NextLogo(
{ {
'--size': SIZE, '--size': SIZE,
'--duration-short': `${SHORT_DURATION_MS}ms`, '--duration-short': `${SHORT_DURATION_MS}ms`,
// if the indicator is disabled and there are no errors, hide the badge // if the indicator is disabled, hide the badge
display: disabled && !hasError ? 'none' : 'block', // also allow the "disabled" state be dismissed, as long as there are no build errors
display: disabled && (!hasError || dismissed) ? 'none' : 'block',
} as React.CSSProperties } as React.CSSProperties
} }
> >
...@@ -226,9 +230,7 @@ export const NextLogo = forwardRef(function NextLogo( ...@@ -226,9 +230,7 @@ export const NextLogo = forwardRef(function NextLogo(
gap: 2px; gap: 2px;
align-items: center; align-items: center;
padding-left: 8px; padding-left: 8px;
padding-right: ${disabled || isBuildError padding-right: ${isBuildError ? '8px' : 'calc(2px * 2)'};
? '8px'
: 'calc(2px * 2)'};
height: var(--size-32); height: var(--size-32);
margin: 0 2px; margin: 0 2px;
border-radius: var(--rounded-full); border-radius: var(--rounded-full);
...@@ -422,7 +424,7 @@ export const NextLogo = forwardRef(function NextLogo( ...@@ -422,7 +424,7 @@ export const NextLogo = forwardRef(function NextLogo(
<div <div
data-next-badge data-next-badge
data-error={hasError} data-error={hasError}
data-error-expanded={isErrorExpanded} data-error-expanded={isExpanded}
data-animate={newErrorDetected} data-animate={newErrorDetected}
style={{ style={{
width: hasError && width > SIZE_PX ? width : SIZE, width: hasError && width > SIZE_PX ? width : SIZE,
...@@ -441,7 +443,7 @@ export const NextLogo = forwardRef(function NextLogo( ...@@ -441,7 +443,7 @@ export const NextLogo = forwardRef(function NextLogo(
<NextMark isLoading={isLoading} isDevBuilding={isDevBuilding} /> <NextMark isLoading={isLoading} isDevBuilding={isDevBuilding} />
</button> </button>
)} )}
{isErrorExpanded && ( {isExpanded && (
<div data-issues> <div data-issues>
<button <button
data-issues-open data-issues-open
...@@ -470,12 +472,16 @@ export const NextLogo = forwardRef(function NextLogo( ...@@ -470,12 +472,16 @@ export const NextLogo = forwardRef(function NextLogo(
)} )}
</div> </div>
</button> </button>
{!disabled && !isBuildError && ( {!isBuildError && (
<button <button
data-issues-collapse data-issues-collapse
aria-label="Collapse issues badge" aria-label="Collapse issues badge"
onClick={() => { onClick={() => {
setIsErrorExpanded(false) if (disabled) {
setDismissed(true)
} else {
setIsErrorExpanded(false)
}
// Move focus to the trigger to prevent having it stuck on this element // Move focus to the trigger to prevent having it stuck on this element
triggerRef.current?.focus() triggerRef.current?.focus()
}} }}
......
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