Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dev-overlay]: allow disabled state to be dismissable #76572

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export const NextLogo = forwardRef(function NextLogo(
shouldSkip: (count) => count === 0,
animationDuration: SHORT_DURATION_MS,
})
const [dismissed, setDismissed] = useState(false)

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

const isExpanded = isErrorExpanded || disabled

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