feat(cms-sections): variant drag-and-drop reorder + variant-aware preview#4173
Open
aka-sacci-ccr wants to merge 1 commit into
Open
feat(cms-sections): variant drag-and-drop reorder + variant-aware preview#4173aka-sacci-ccr wants to merge 1 commit into
aka-sacci-ccr wants to merge 1 commit into
Conversation
…view - Reorder section and page variants via dnd-kit - Force the preview to render the selected variant through the deco runtime's x-deco-matchers-override (section + page level), only on explicit variant click - Preserve preview scroll across override navigations/save-reloads via the injected CMS script (sessionStorage + retried restore) Co-authored-by: Cursor <cursoragent@cursor.com>
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
SectionVariantList) and page variants (PageVariantTabs) are now reorderable via dnd-kit, with a newreorderMultivariateSectionVariantop andonReorderhandlers that follow the moved/selected variant. Order is semantically meaningful (deco renders the first matching variant), so this lets users control precedence.x-deco-matchers-overridequery param. New pure, unit-tested helpervariant-matcher-override.tsbuilds the override ids for inline matchers (dotted resolve-chain path, incl. the.sectionsegment for Lazy-wrapped sections and page-variant nesting) and saved matcher blocks (resolveType).sessionStorageand restores it (with retries to outlast re-hydration) across the override navigation and the post-save reload, so the preview no longer jumps to the top.Files
section-variants.ts(+ test):reorderMultivariateSectionVariantsection-variant-list.tsx: dnd-kit sortable listsections-editor.tsx: reorder handlers, gatedsyncVariantPreviewOverride, page-variant override wiringvariant-matcher-override.ts(+ test): override-id/param builderssandbox/preview/preview.tsx+cms-editor-script.ts: apply override to iframe src, scroll persistenceTest plan
bun run check,bun run lint,bun run fmt:check,bun testfor the touched units.Made with Cursor
Summary by cubic
Adds drag‑and‑drop reordering for section and page variants, and makes the preview render the exact variant you click using matcher overrides, with scroll preserved during reloads.
@dnd-kit/*with a newonReorderhandler; selection follows the moved item.reorderMultivariateSectionVariantop to persist variant order.x-deco-matchers-override; helpersbuildSectionVariantOverrideParams,buildPageVariantOverrideParams, andwithVariantMatcherOverride(unit‑tested).Written for commit c418a4b. Summary will update on new commits.