feat(VB-2055): add isVisualEditorEditing helper - #629
Merged
Conversation
🔒 Security Scan Results
⏱️ SLA Breach Summary
✅ BUILD PASSED - All security checks passed |
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||
Expose isVisualEditorEditing(element) so a site can pause self-updating content (CSS animations, carousels, polled/streamed data) while a field is being edited in Visual Editor. It reads the existing data-cslp-field-type marker the SDK already sets on the focused element, is side-effect-free, and returns false during SSR. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
karancs06
force-pushed
the
VB-2055-is-visual-builder-editing
branch
from
July 28, 2026 12:46
0fe2bdf to
23dcbe4
Compare
🔒 Security Scan Results
⏱️ SLA Breach Summary
✅ BUILD PASSED - All security checks passed |
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
Adds
isVisualEditorEditing(element), a small helper that tells a site whether a field is currently being edited in Visual Editor. Sites can use it to pause self-updating content (CSS animations, carousels, polled or streamed data) while an author edits, then resume afterwards. Without it, such content keeps mutating the DOM under the editor and the edit form resyncs to a moving target.Changes
src/visualBuilder/utils/editingState.ts— newisVisualEditorEditing(element?). Returnstruewhileelement(or a descendant) carries the existingdata-cslp-field-typemarker the SDK already sets on the focused field;falseotherwise. Pass an element to scope the check, or omit it to check the whole document.src/index.ts— export the helper from the package entry.Screen.Recording.2026-07-28.at.4.16.12.PM.mov
Notes:
falsewhen there is no DOM.Test plan
editingStateunit tests pass (6): false when idle, true for a descendant edit, true when the element itself is the marker, scoped-to-element, document-wide, and SSR no-op.tsc --noEmitclean; lint clean.🤖 Generated with Claude Code