Switch styled element by clicking while the Style panel is open#468
Merged
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
commit: |
Contributor
There was a problem hiding this comment.
2 issues found across 8 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
…is open Clicking another element on the page while the edit (Style) panel is open now switches the edit session to that element instead of dismissing the panel. Applied inline styles are kept when switching, the session compounds edits across elements, copying emits one prompt entry per styled element, and discarding restores every element touched during the session. Co-authored-by: Aiden Bai <aidenybai@users.noreply.github.com>
switchToElement resolves an element's source asynchronously, so a fast switch could bank a session record (or submit) before resolution landed, emitting a CSS block with no file:line header for that element. Patch any already-recorded visit when resolution arrives (not just live state) and prefer a non-empty source when merging a revisited element's entries. Also dedupe the session-record construction via a shared helper and drop the now-unused CARD_SELECTOR test export.
f9e2b5d to
4b5084a
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 4b5084a. Configure here.
A switched-away element can bank a session record with no net edits but live preview styles (tweaked then stepped back to original). Those never reach the copied prompt, yet submit's clearAll dropped them without restoring, leaving stray inline styles on the page that the copy never described — unlike discard, which restores them. Submit now reverts any banked visit whose element contributed no edits to the prompt. Adds an e2e covering copy after a switched-away element's tweak is undone.
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.

Summary
While the Style (edit) panel is open, clicking another element on the page now switches the editing session to that element instead of dismissing the panel. Edits compound across elements within a single session:
Implementation
core/edit-mode.ts: the controller now tracks per-visit session records (element, preview, edits, source location) and exposesswitchToElementplussetPendingEdits. Prompt formatting moved here from the panel so the compound prompt is built from the whole session. The new element's source path is resolved asynchronously since the store's selection source still points at the previous element.core/index.tsx: windowpointerdownwhile the panel is open resolves a grabbable element under the cursor and switches to it (consuming the gesture); the follow-upclickis suppressed so page buttons/links don't activate when picked.components/edit-panel/index.tsx: reports pending edits to the controller on every commit, gates dismiss/submit affordances on session edits, and no longer clears preview baselines on unmount (the controller owns restore-on-discard across switches).utils/preview-styles.ts: removed the now-unusedforget.Testing
edit-panel.spec.ts("Element switching"): switch keeps applied styles and retargets tweaks; compound copy produces two CSS blocks; discard restores all elements; discard prompt stays armed after switching with no new tweaks.pnpm test(658 passed, 1 unrelated flaky that passes in isolation),pnpm lint,pnpm typecheck,pnpm formatall green.Summary by cubic
Switch the styled element by clicking another element while the Style panel is open. Edits persist across elements so you can copy or discard the whole session at once, and copy now reverts preview‑only elements to avoid stray inline styles.
New Features
Migration
onEditPanelSubmitnow receivesPendingEditsinstead of a formatted prompt.onEditPanelPendingEditsChangereports livePendingEdits.PreviewStyles.forget()was removed.Written for commit 739dfa4. Summary will update on new commits.