Skip to content

[dev-overlay] Fix error dialog resizing logic#77830

Merged
devjiwonchoi merged 4 commits into
canaryfrom
rf/dialog-resizing
Apr 4, 2025
Merged

[dev-overlay] Fix error dialog resizing logic#77830
devjiwonchoi merged 4 commits into
canaryfrom
rf/dialog-resizing

Conversation

@raunofreiberg

@raunofreiberg raunofreiberg commented Apr 4, 2025

Copy link
Copy Markdown
Member

This PR improves our height resizing strategy. Animating the height on page load or when the dialog opens is not ideal and it would be better if the dialog would just fade in and assume it's intrinsic height without motion.

This is what happens before this PR when you open errors, and it can be distracting to experience such amount of motion at once:

CleanShot.2025-04-04.at.14.10.28.mp4

The reason this happens is because some of the dialog contents load in async—for example the errors are actually suspended so that the message can be viewed without waiting for the stack frames to load:

<Suspense fallback={<div data-nextjs-error-suspended />}>
<RuntimeError
key={activeError.id.toString()}
error={activeError}
dialogResizerRef={dialogResizerRef}
/>
</Suspense>


After this PR, we still measure the height of the dialog and animate it in response to user input, but only use the value when the height has stabilised. You can see what happens by observing the blue height value:

CleanShot.2025-04-04.at.14.28.19.mp4

And another video from the fixture app:

CleanShot.2025-04-04.at.15.50.16.mp4

Closes NDX-983

Comment on lines -92 to -103
useEffect(() => {
// Close the error overlay when pressing escape
function handleKeyDown(event: KeyboardEvent) {
if (event.key === 'Escape') {
onClose()
}
}

document.addEventListener('keydown', handleKeyDown)
return () => document.removeEventListener('keydown', handleKeyDown)
}, [onClose])

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already handled by the Dialog component. The logic here was also making the dialog dismiss when closing the Dev Tools popover with Escape

</DialogContent>
<ErrorOverlayBottomStack
errorCount={runtimeErrors?.length ?? 0}
errorCount={errorCount}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the same errorCount variable as introduced in #77821

@ijjk

ijjk commented Apr 4, 2025

Copy link
Copy Markdown
Member

Tests Passed

@devjiwonchoi devjiwonchoi merged commit 5ff57ea into canary Apr 4, 2025
@devjiwonchoi devjiwonchoi deleted the rf/dialog-resizing branch April 4, 2025 15:42
huozhi added a commit that referenced this pull request Apr 4, 2025
huozhi added a commit that referenced this pull request Apr 4, 2025
Reverts #77830

This was breaking the react 18.3 tests, where the toggling stack frames
is not working in 18.3. Possibly broken by the ref related changes.

x-ref:
https://github.com/vercel/next.js/actions/runs/14274082641/job/40015934515
@raunofreiberg raunofreiberg restored the rf/dialog-resizing branch April 14, 2025 12:50
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Apr 29, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants