Skip to content

fix: take the survey card rect from the renderer instead of scraping the DOM [ENG-3155] - #56

Open
pandeymangg wants to merge 1 commit into
mainfrom
anshuman/eng-3155-flutter-sdk-consume-oncardrectchange-instead-of-scraping-the
Open

pandeymangg wants to merge 1 commit into
mainfrom
anshuman/eng-3155-flutter-sdk-consume-oncardrectchange-instead-of-scraping-the

Conversation

@pandeymangg

Copy link
Copy Markdown
Contributor

Ref ENG-3155

Release only after formbricks/formbricks#9242 is deployed. This drops the DOM probe, so until the renderer reports the card rect a no-overlay survey blocks the host app again (the pre-#46 behaviour, not a dead card). Siblings: formbricks/ios#57, formbricks/android#87, formbricks/react-native#81.

What & why

Was: the SDK found the survey card by scraping the renderer's DOM (#fbjs [role="dialog"]). That broke once already when an a11y fix moved the attribute it matched, and a missing rect made the card itself untappable, because the mask read "no rect" as "claim nothing".

Now: the renderer reports the card rect through onCardRectChange, and the mask has three states: no rect yet blocks everything (as before the mask existed), a rect passes touches outside the card through, null claims nothing.

Where to look

  • widgets/survey_touch_region.dart: the three states.
  • widgets/survey_html.dart: the probe and its rAF/MutationObserver loop are gone; onCardRectChange is passed into renderSurvey.
  • widgets/survey_webview.dart: the mask starts at everything.

Coverage

Behaviour Level
overlay: none: host scrolls beside the card, card works inside, nothing left after close manual: playground on the iPhone 17 simulator, local #9242 web
A survey with no rect reported yet takes the tap instead of passing it through unit (red on main): non-overlay before geometry arrives: the survey takes the tap
Card gone claims nothing; no-rect state stays distinct unit (mutation): survey_touch_region.dart:39 null → everything (3 tests fail)
Region per state, card edges unit (guard): survey_touch_region_test.dart

Rerun: cd packages/formbricks && flutter test test/widgets/survey_webview_test.dart --plain-name "non-overlay before geometry arrives" — fails with main's survey_html.dart / survey_webview.dart (1 host tap, expected 0), passes here.

Full suite: 346 tests; flutter analyze clean.

Open gaps

  • iOS simulator only; Android not run by hand (the mask is the same Dart code on both).

Breaking changes

  • This PR contains a breaking change

No public API change.

@coderabbitai

coderabbitai Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: aa3c3a01-9a77-4949-bbf1-e293b3d99843

📥 Commits

Reviewing files that changed from the base of the PR and between 50d3cd8 and 2402444.

📒 Files selected for processing (5)
  • packages/formbricks/lib/src/widgets/survey_html.dart
  • packages/formbricks/lib/src/widgets/survey_touch_region.dart
  • packages/formbricks/lib/src/widgets/survey_webview.dart
  • packages/formbricks/test/widgets/survey_touch_region_test.dart
  • packages/formbricks/test/widgets/survey_webview_test.dart

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.


Walkthrough

The survey HTML no longer polls or observes the DOM for card geometry. It forwards rectangles supplied by the renderer as Geometry messages. SurveyTouchRegion represents everything, nothing, or a card rectangle. The WebView starts by accepting all pointer hits, then updates its region when it receives geometry. Overlay placements continue to bypass the pointer mask.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to 24024

The change makes the survey card touch region follow renderer-reported geometry and keeps the card tappable before geometry arrives. No merge-blocking risk was identified. Release it only after the companion renderer change is deployed, as the author notes.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description check ✅ Passed The description clearly explains the renderer-provided card geometry, the three touch-region states, release dependency, testing, and known Android validation gap.
Title check ✅ Passed The title clearly identifies the primary change: using the renderer’s survey card rectangle instead of scraping the DOM.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sonarqubecloud

Copy link
Copy Markdown

@pandeymangg
pandeymangg requested a review from itsjavi September 30, 2026 14:43
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