You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(core): ignore suggestion menu scrolls from another realm - #3398
Fixes#3382. The suggestion menu scroll handler now ignores a scroll of the menu itself when the event target comes from another JavaScript realm, such as a same-origin iframe that host-page code manages.
Rationale
SuggestionMenuView.handleScroll skipped scrolls whose target does not contain the decoration, but only when event.target instanceof Node. A node from an iframe's document is not an instance of the host page's Node, so the check was false, the filter was skipped, and a scroll inside the menu moved the menu's reference position.
Changes
The guard checks that the target has a contains function instead of using instanceof Node. A Window target still falls through and updates the position, as before.
Impact
None for the normal same-document case. Scrolling an ancestor of the decoration still updates the position.
Testing
New unit test in SuggestionMenu.test.ts: it opens the menu, then dispatches a scroll whose target is a node created by an iframe's document, then a scroll on document.body. On main the first scroll causes 1 update (expected 0). With the fix it causes 0 and the body scroll causes 1.
vp test run in packages/core: 124 files, all pass.
vp lint --type-aware and vp fmt --check on the changed files, and tsc --noEmit -p packages/core/tsconfig.json: clean.
Checklist
Code follows the project's coding standards.
Unit tests covering the new feature have been added.
All existing tests pass.
The documentation has been updated to reflect the new feature (not needed)
Summary by CodeRabbit
Bug Fixes
Suggestion menus now correctly evaluate scroll events from same-origin iframes, while continuing to ignore events from targets that don’t contain the suggestion.
The scroll guard used the host page's Node constructor, so a scroll
event whose target came from a same-origin iframe skipped the filter
and repositioned the menu. Check for contains() instead.
No actionable comments were generated in the recent review.
Walkthrough
The suggestion-menu scroll handler now checks whether an event target contains the suggestion decoration without requiring the target to be an instance of the current realm’s Node. A test covers scroll events from a same-origin iframe menu and from document.body.
handleScroll checks for a target with a callable contains method and ignores targets that do not contain the suggestion decoration. The test checks that an iframe menu scroll does not update the store, while a body scroll does.
This change makes suggestion-menu scroll filtering work for editors embedded in same-origin iframes. Scrolling ancestors of the decoration still updates the menu position. No actionable merge risk remains.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the fix and its scope: suggestion menu scroll events from another realm are now ignored. It matches the changeset, which changes the handleScroll guard from an instanceof Node check to…
Description check
The description follows the repository template. It has a Summary that states the fix and links issue #3382, a Rationale that explains the instanceof Node failure for iframe nodes, a Changes section, …
Linked Issues check
Issue #3382 requires that a scroll inside the suggestion menu be ignored when the menu is in a same-origin iframe, and that an ancestor scroll still update the position. The reviewed diff in packages/…
Out of Scope Changes check
The whole-PR diff against the merge base bd39cd4 touches two files: SuggestionMenu.ts (the scroll guard, +8/-3 lines, shown in the diff) and SuggestionMenu.test.ts (a regression test for the iframe sc…
Full details: Title check
Explanation
The title names the fix and its scope: suggestion menu scroll events from another realm are now ignored. It matches the changeset, which changes the handleScroll guard from an instanceof Node check to a contains-method check and adds a test for a cross-realm iframe target. It is specific and follows the conventional commit style.
Full details: Description check
Explanation
The description follows the repository template. It has a Summary that states the fix and links issue #3382, a Rationale that explains the instanceof Node failure for iframe nodes, a Changes section, an Impact section, a Testing section with the new unit test and the commands run, and a completed Checklist. The Screenshots/Video and Additional Notes sections are missing. Screenshots are not needed for this change, so this gap is minor.
Full details: Linked Issues check
Explanation
Issue #3382 requires that a scroll inside the suggestion menu be ignored when the menu is in a same-origin iframe, and that an ancestor scroll still update the position. The reviewed diff in packages/core/src/extensions/SuggestionMenu/SuggestionMenu.ts replaces the event.target instanceof Node guard with a check for a callable contains method on the target. A cross-realm iframe node now passes the guard, so target.contains(decorationNode) runs. For a menu node outside the decoration's ancestor chain, this returns false and the handler returns early. A Window target has no contains, so it falls through and updates the position. A null target is also handled. The issue's own requirement is coding-only, and the PR adds a unit test for the iframe case (per the PR description and test summary). The test file was not read directly in this assessment; the test result relies on the author's description and the change summary. The issue states that a full editor/Floating UI integration was not tested, and no such requirement is imposed.
Full details: Out of Scope Changes check
Explanation
The whole-PR diff against the merge base bd39cd4 touches two files: SuggestionMenu.ts (the scroll guard, +8/-3 lines, shown in the diff) and SuggestionMenu.test.ts (a regression test for the iframe scroll case, +43/-1 lines, per the change summary). Both changes relate directly to the linked issue. No unrelated change was found. The test file content was not read directly, so this assessment is based on the change summary for that file.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Fix failing CI checks
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
A rabbit watched the menu scroll, An iframe’s node passed through the fold. The handler checked what it contained, The menu stayed still; the test confirmed. Then body scrolls refreshed its place, And rabbit hopped with quiet grace.
Recent review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: bf0d7ffb-1e1d-4ceb-88d8-a3f9ec653bcc
Commits
Reviewing files that changed from the base of the PR and between bd39cd4 and 3cfbb81.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
This branch has not been deployed
No deployments
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
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
Fixes #3382. The suggestion menu scroll handler now ignores a scroll of the menu itself when the event target comes from another JavaScript realm, such as a same-origin iframe that host-page code manages.
Rationale
SuggestionMenuView.handleScrollskipped scrolls whose target does not contain the decoration, but only whenevent.target instanceof Node. A node from an iframe's document is not an instance of the host page'sNode, so the check was false, the filter was skipped, and a scroll inside the menu moved the menu's reference position.Changes
containsfunction instead of usinginstanceof Node. AWindowtarget still falls through and updates the position, as before.Impact
None for the normal same-document case. Scrolling an ancestor of the decoration still updates the position.
Testing
SuggestionMenu.test.ts: it opens the menu, then dispatches a scroll whose target is a node created by an iframe's document, then a scroll ondocument.body. Onmainthe first scroll causes 1 update (expected 0). With the fix it causes 0 and the body scroll causes 1.vp test runinpackages/core: 124 files, all pass.vp lint --type-awareandvp fmt --checkon the changed files, andtsc --noEmit -p packages/core/tsconfig.json: clean.Checklist
Summary by CodeRabbit