Skip to content

feat(VB-2055): add isVisualEditorEditing helper - #629

Merged
karancs06 merged 1 commit into
develop_v4from
VB-2055-is-visual-builder-editing
Jul 28, 2026
Merged

feat(VB-2055): add isVisualEditorEditing helper#629
karancs06 merged 1 commit into
develop_v4from
VB-2055-is-visual-builder-editing

Conversation

@karancs06

@karancs06 karancs06 commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

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 — new isVisualEditorEditing(element?). Returns true while element (or a descendant) carries the existing data-cslp-field-type marker the SDK already sets on the focused field; false otherwise. 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.
  • Unit tests for the helper (element scoping, document-wide, SSR).
Screen.Recording.2026-07-28.at.4.16.12.PM.mov

Notes:

  • Side-effect-free: a plain check with no observer or subscription to manage. The consumer decides how to read it (interval, animation loop, framework effect, on demand).
  • SSR-safe: returns false when there is no DOM.
  • Purely additive and backward compatible: a new named export with no runtime side effects, so it tree-shakes out for consumers that do not use it. It relies only on the pre-existing attribute, so it also works for sites on older SDK versions.

Test plan

  • New editingState unit 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 --noEmit clean; lint clean.
  • Verified in a sample app: a 3s slideshow and a continuously scrolling feed pause while their fields are edited in Visual Editor and resume on blur, with no effect outside Visual Editor.

🤖 Generated with Claude Code

@karancs06
karancs06 requested review from a team as code owners July 28, 2026 10:50
@github-actions

Copy link
Copy Markdown

🔒 Security Scan Results

ℹ️ Note: Only vulnerabilities with available fixes (upgrades or patches) are counted toward thresholds.

Check Type Count (with fixes) Without fixes Threshold Result
🔴 Critical Severity 0 0 10 ✅ Passed
🟠 High Severity 0 0 25 ✅ Passed
🟡 Medium Severity 0 0 500 ✅ Passed
🔵 Low Severity 1 0 1000 ✅ Passed

⏱️ SLA Breach Summary

✅ No SLA breaches detected. All vulnerabilities are within acceptable time thresholds.

Severity Breaches (with fixes) Breaches (no fixes) SLA Threshold (with/no fixes) Status
🔴 Critical 0 0 15 / 30 days ✅ Passed
🟠 High 0 0 30 / 120 days ✅ Passed
🟡 Medium 0 0 90 / 365 days ✅ Passed
🔵 Low 0 0 180 / 365 days ✅ Passed

✅ BUILD PASSED - All security checks passed

@github-actions

github-actions Bot commented Jul 28, 2026

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 67.36% 2524 / 3747
🔵 Statements 66.22% 2563 / 3870
🔵 Functions 64.56% 450 / 697
🔵 Branches 61.9% 1529 / 2470
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/index.ts 100% 100% 100% 100%
src/visualBuilder/utils/editingState.ts 100% 100% 100% 100%
Generated in workflow #873 for commit 23dcbe4 by the Vitest Coverage Report Action

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
karancs06 force-pushed the VB-2055-is-visual-builder-editing branch from 0fe2bdf to 23dcbe4 Compare July 28, 2026 12:46
@karancs06 karancs06 changed the title feat(VB-2055): add isVisualBuilderEditing helper feat(VB-2055): add isVisualEditorEditing helper Jul 28, 2026
@github-actions

Copy link
Copy Markdown

🔒 Security Scan Results

ℹ️ Note: Only vulnerabilities with available fixes (upgrades or patches) are counted toward thresholds.

Check Type Count (with fixes) Without fixes Threshold Result
🔴 Critical Severity 0 0 10 ✅ Passed
🟠 High Severity 0 0 25 ✅ Passed
🟡 Medium Severity 0 0 500 ✅ Passed
🔵 Low Severity 1 0 1000 ✅ Passed

⏱️ SLA Breach Summary

✅ No SLA breaches detected. All vulnerabilities are within acceptable time thresholds.

Severity Breaches (with fixes) Breaches (no fixes) SLA Threshold (with/no fixes) Status
🔴 Critical 0 0 15 / 30 days ✅ Passed
🟠 High 0 0 30 / 120 days ✅ Passed
🟡 Medium 0 0 90 / 365 days ✅ Passed
🔵 Low 0 0 180 / 365 days ✅ Passed

✅ BUILD PASSED - All security checks passed

@hitesh-shetty-cstk hitesh-shetty-cstk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!!

@karancs06
karancs06 merged commit de12611 into develop_v4 Jul 28, 2026
9 checks passed
@karancs06
karancs06 deleted the VB-2055-is-visual-builder-editing branch July 28, 2026 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants