-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[PM-27798] Prevent inline menu from opening on the page outside of the viewport #17664
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unrelated cleanup
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
verified in testing that these values can explicitly be null
| /** | ||
| * Check if element is completely within the browser viewport. | ||
| */ | ||
| private isElementCompletelyWithinViewport(elementPosition: DOMRect) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While this can be used for any element, it is currently only employed for checking the (newly initialized) inline menu iframe
| root: null, | ||
| rootMargin: "0px", | ||
| threshold: 1.0, | ||
| threshold: 0.9999, // Safari doesn't seem to function properly with a threshold of 1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unrelated change (to match the same pattern used in apps/browser/src/autofill/services/autofill-overlay-content.service.ts)
|
Fixed Issues (1)Great job! The following issues were fixed in this Pull Request
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #17664 +/- ##
=======================================
Coverage 41.53% 41.54%
=======================================
Files 3551 3551
Lines 102239 102255 +16
Branches 15340 15348 +8
=======================================
+ Hits 42465 42481 +16
Misses 57985 57985
Partials 1789 1789 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Changes in this PR impact the Autofill experience of the browser clientBIT has tested the core experience with these changes and all feature flags disabled. ✅ Fortunately, these BIT tests have passed! 🎉 |
Changes in this PR impact the Autofill experience of the browser clientBIT has tested the core experience with these changes and the feature flag configuration used by ✅ Fortunately, these BIT tests have passed! 🎉 |
|
Claude finished @jprusik's task —— View job Code Review CompleteI've reviewed the PR and the implementation looks solid. The viewport checking logic is well-implemented with comprehensive test coverage. Here are my findings: Finding 1: Early return prevents fade-in animation execution💭 In Contextprivate updateIframePosition(position: Partial<CSSStyleDeclaration>) {
if (!globalThis.document.hasFocus()) {
return;
}
const styles = this.fadeInTimeout ? Object.assign(position, { opacity: "0" }) : position;
this.updateElementStyles(this.iframe, styles);
const elementHeightCompletelyInViewport = this.isElementCompletelyWithinViewport(
this.iframe.getBoundingClientRect(),
);
if (!elementHeightCompletelyInViewport) {
this.forceCloseInlineMenu();
return; // Prevents fade-in below
}
if (this.fadeInTimeout) {
this.handleFadeInInlineMenuIframe();
}
// ...
}The early return is correct, but a comment like "// Close menu before animation if outside viewport" might help future maintainers. Finding 2: Visual Viewport API preference is well-justified👍 The use of Finding 3: Test coverage is comprehensive👍 The test suite added 253 lines covering all edge cases:
This is thorough testing that gives confidence in the implementation. Finding 4: Type safety improvement for InlineMenuPosition👍 Changing Finding 5: Unrelated cleanup changes are appropriate👍 The TOTP comment fixes in SummaryThis PR successfully implements viewport boundary checking for the inline menu with no significant issues found. The implementation is clean, well-tested, and handles edge cases appropriately. The code follows established patterns in the codebase and the test coverage is excellent. No blocking issues identified. The PR is ready to merge from a code quality perspective. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One minor nit, but I'll leave it to your discretion whether you want to address it. Great work here!
| topSideIsWithinViewport && | ||
| bottomSideIsWithinViewport | ||
| ); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this be collapsed to a single return expression and avoid the consts for reduced lines?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, I had also considered early returns for each check as well, but it felt a little overkill to me and harder to quickly scan/understand for marginal perf gain.
The verbosity is okay in my mind to help signal intent, but we could revisit it in future work if you don't consider this a blocking concern.


🎟️ Tracking
PM-27798
📔 Objective
Add checks to verify the inline menu is fully within the viewport. Dismiss it otherwise.
📸 Screenshots
Before
show-inline-menu-if-outside-viewport.mp4
After
hide-inline-menu-if-outside-viewport.mp4
🦮 Reviewer guidelines
:+1:) or similar for great changes:memo:) or ℹ️ (:information_source:) for notes or general info:question:) for questions:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion:art:) for suggestions / improvements:x:) or:warning:) for more significant problems or concerns needing attention:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt:pick:) for minor or nitpick changes