fix(core): clamp popovers to viewport#461
Merged
Merged
Conversation
@vitejs/devtools
@vitejs/devtools-kit
@vitejs/devtools-oxc
@vitejs/devtools-rolldown
@vitejs/devtools-vite
@vitejs/devtools-vitest
commit: |
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes dock/tooltip popovers overflowing the viewport in embedded floating/edge dock modes by introducing viewport-aware positioning with panel-size measurement and adding targeted regression coverage.
Changes:
- Refactors
FloatingPopoverto delegate positioning to a newresolveFloatingPosition()helper and measure panel dimensions for clamping. - Adds
floating-position.tsresolver to handle alignment guessing, side flipping, and cross-axis clamping. - Adds Storybook coverage (corner anchors) and Vitest unit tests for the new positioning logic.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/core/src/client/webcomponents/components/floating/FloatingPopover.ts | Measures popover size and uses shared resolver to compute styles, enabling clamped positioning. |
| packages/core/src/client/webcomponents/components/floating/FloatingPopover.stories.ts | Adds a corner-anchor harness to visually validate viewport clamping. |
| packages/core/src/client/webcomponents/components/floating/floating-position.ts | Introduces centralized positioning logic (guess/flip/clamp). |
| packages/core/src/client/webcomponents/components/floating/tests/floating-position.test.ts | Adds unit tests covering alignment selection, flipping, clamping, and first-paint behavior. |
Comments suppressed due to low confidence (1)
packages/core/src/client/webcomponents/components/floating/floating-position.ts:90
- For left/right placements, the main axis position isn’t clamped even when
panelWidthis known. This means wide popovers can still overflow past the viewport edge (especially whenplacementis explicit and flipping is disabled). Clamping the computedleft/rightkeeps the popover withinVIEWPORT_MARGIN.
else {
if (align === 'right')
style.left = `${anchorRight + gap}px`
else
style.right = `${vw - rect.left + gap}px`
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Close #459