Restyle playground edit toggles and fix stale toggle state#1016
Merged
Conversation
The playground's per-file "Edit" control was a bare checkbox in each of the three views (CodeView, React Virtualizer, and vanilla Virtualizer). It is now a bordered pill button: a filled checkbox plus "Editing" when active, an outline icon plus "Edit" when idle. Styling is shared through one `.playground-edit-toggle` class in globals.css, driven by `aria-pressed`. Both state icons and both labels are always present so CSS shows the matching pair. The vanilla view builds its DOM by hand and inlines the two glyphs as SVG, so it only has to flip the attribute; its metadata slot is light-DOM, so the app stylesheet reaches it.
Toggle Edit on a file in the playground's React Virtualizer view: the button's pressed state lagged one click behind, showing the previous value instead of the current one. renderHeaderMetadata read `editing` from the render closure but was wrapped in useStableCallback, which only refreshes its inner ref in a commit-phase insertion effect. FileDiff calls the callback during render, so it ran the previous render's closure. Use a useCallback keyed on `editing` so each toggle renders with the current value.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
amadeus
approved these changes
Jul 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Redesigns the playground's per-file Edit toggle across all three views and fixes a state-sync bug surfaced by the new design.
.playground-edit-toggleclass inglobals.css, driven byaria-pressed, with both state icons and both labels always present so CSS shows the matching pair.aria-pressedon click.renderHeaderMetadataread render-phaseeditingbut was wrapped inuseStableCallback(which only refreshes in a commit-phase insertion effect) whileFileDiffinvokes it during render. Switch that callback to auseCallbackkeyed onediting. The old native checkbox masked this; the newaria-pressedbutton made it visible.