[dev-v5][Popover] React to ViewPort changes#4884
Open
MarvinKlein1508 wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR improves popover positioning behavior on viewport changes (notably iOS visual viewport/keyboard changes) by listening to visualViewport events, throttling reposition work to the next animation frame, and adjusting placement calculations to account for visual viewport offsets.
Changes:
- Add
visualViewportscroll/resize listeners alongside existing window listeners. - Debounce/reduce repeated reposition calls via
requestAnimationFrame(and cancel any pending frame on disconnect). - Update “available space” calculations to incorporate visual viewport top/left offsets.
Comment on lines
+314
to
+317
| const spaceAbove = rect.top - viewportTop; | ||
| const spaceBelow = viewportBottom - rect.bottom; | ||
| const spaceLeft = rect.right - viewportLeft; | ||
| const spaceRight = viewportRight - rect.left; |
Comment on lines
68
to
+71
| window.addEventListener('scroll', this.handleWindowChange, true); | ||
| window.addEventListener('resize', this.handleWindowChange, true); | ||
| window.visualViewport?.addEventListener('scroll', this.handleWindowChange); | ||
| window.visualViewport?.addEventListener('resize', this.handleWindowChange); |
Comment on lines
67
to
72
| connectedCallback() { | ||
| window.addEventListener('scroll', this.handleWindowChange, true); | ||
| window.addEventListener('resize', this.handleWindowChange, true); | ||
| window.visualViewport?.addEventListener('scroll', this.handleWindowChange); | ||
| window.visualViewport?.addEventListener('resize', this.handleWindowChange); | ||
| } |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Pull Request
📖 Description
This PR is a follow-up for #4872 and #4882. It enhances the
FluentPopovercomponent by reacting to changes with to the viewPort by attachingscrollandresizeevent handlers to theFluentPopover. This event handlers recalculate the position for the current view port.This improves the component use-age in scenarios where virtual keyboards are being displayed or hided like in
FluentAutocomplete.Before:
WhatsApp.Video.2026-05-21.at.14.59.05.mp4
After:
WhatsApp.Video.2026-05-21.at.14.59.07.mp4
I have tested this changes in Firefox, Chrome, Edge and on Safari both on macOS and iOS.
🎫 Issues
Fixes #4878
✅ Checklist
General
Component-specific
⏭ Next Steps