fix(visual-builder): keep overlayPropagation from piercing the SDK's own toolbar#617
Conversation
…own toolbar With overlayPropagation enabled, clicks landing on the visual builder's own UI (field toolbar, overlays) were resolved through document.elementsFromPoint and could hit a data-cslp element rendered underneath. A click on the edit (pencil) button then also counted as a canvas click on the overlapped field, sending a focus event for the wrong entry and breaking the edit modal's apply flow. Skip the elementsFromPoint fallback whenever the click target sits inside .visual-builder__container: the fallback exists to pierce the website's own overlapping elements, never the SDK's chrome.
🔒 Security Scan Results
⏱️ SLA Breach Summary
✅ BUILD PASSED - All security checks passed |
There was a problem hiding this comment.
Pull request overview
This PR fixes an interaction bug in the Visual Builder where overlayPropagation.enable could incorrectly “pierce” the SDK’s own chrome (toolbar/overlays) via the elementsFromPoint fallback and resolve clicks to an underlying data-cslp element on the canvas.
Changes:
- Skip the
document.elementsFromPoint()fallback when the click target is inside.visual-builder__container. - Add a unit test ensuring toolbar/UI clicks do not resolve to underlying
data-cslpelements and thatelementsFromPointis not invoked.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/visualBuilder/utils/getCsDataOfElement.ts | Prevents overlay propagation fallback from piercing the Visual Builder UI container. |
| src/visualBuilder/utils/test/getCsDataOfElement.test.ts | Adds coverage for Visual Builder UI clicks with overlayPropagation enabled. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||
…pagation-toolbar-pierce
|
The change itself looks right and low-risk. Everything the SDK renders (toolbar, overlays, add buttons) mounts under Two things I'd want to confirm before we treat this as the fix for VB-1958 rather than a good hardening on its own:
Also, can we add VB-1958 to the description so the two are linked? On Copilot's note: agree it's worth folding |
contentstackMridul
left a comment
There was a problem hiding this comment.
Approved with comment
…dition Run the closest() check only when the overlayPropagation fallback is enabled and no field matched, so hover events skip the extra DOM traversal in the common case.
|
Thanks — applied your and Copilot's suggestion: the guard is folded into the fallback condition with On 1: you're right, and that's the key finding — the
Reproduced deterministically with a heading from one referenced entry rendered flush above an RTE from another: the field label flashes the heading field's name when clicking the pencil, and removing the fallback flag makes the whole thing vanish. On 2: agreed, the guard only engages with |
🔒 Security Scan Results
⏱️ SLA Breach Summary
✅ BUILD PASSED - All security checks passed |
We don't link jira details on public repo to avoid leaking any internal details. |
Summary
With
overlayPropagation.enableset, clicks that land on the visual builder's own UI (the field toolbar, overlays, add buttons) were resolved throughdocument.elementsFromPoint()and could hit adata-cslpelement rendered underneath the SDK's chrome.In practice: when a page renders a heading from one entry directly above a rich text field from another entry, the focused field's toolbar sits on top of the heading. Clicking the toolbar's edit (pencil) button then also registered as a canvas click on the heading, because the SDK's capture-phase click listener runs before the button's own handler can stop propagation. That sent a focus event for the wrong entry while the edit modal opened for the right one, and the modal's Apply was lost.
Changes
getCsDataOfElementskips theelementsFromPointfallback whenever the click target sits inside.visual-builder__container. The fallback exists to pierce the website's own empty overlapping elements (its original purpose, e.g. CSS grid spacer cells), never the SDK's own UI.Test plan
overlayPropagationenabled, a click on an element inside the visual builder container does not resolve to thedata-cslpelement underneath, andelementsFromPointis not called.getCsDataOfElementand listener suites pass (30 tests).