Conversation
Contributor
Author
|
/build |
Contributor
|
Branch: |
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.
Cross-resolution verification
📊 Full evidence page — measurements and before/after screenshots
Problem
On narrow viewports a tooltip with a long text overflowed the left edge of the screen and became unreadable, instead of fitting into the viewport.
Measured on the
Tooltip / Interactivestory at a 320 px viewport:left: -170px,width: 490px.Two causes stack up:
Tooltip.vuepassed a hardcodeddt.maxWidth: '900px', which ignores the screen width entirely, so the tooltip was simply wider than the viewport.alignTop/alignBottomsetleft = triggerLeft + (triggerWidth - tooltipWidth) / 2, andisOutOfBoundsonly ever flips betweentopandbottom. Centering a wide tooltip on a narrow screen yields a negativeleft.Changes
Tooltip.consts.ts— new constants:TOOLTIP_MAX_WIDTH_PX,TOOLTIP_VIEWPORT_MARGIN_PX(8 px),TOOLTIP_ARROW_EDGE_INSET_PX.Tooltip.utils.ts(new) — pure helpersgetTooltipViewportFitShiftandgetTooltipArrowOffset.Tooltip.vue:maxWidthis nowmin(900px, calc(100vw - 16px)), so the tooltip is never wider than the screen;MutationObserverpicks the tooltip up as it is appended tobodyand nudges it back into the viewport. PrimeVue positions the element synchronously right aftercreate(), so the correction lands before paint — no flicker;Tooltip.spec.ts(new) — 9 regression tests covering the fit logic.One thing worth calling out: the tooltip uses
width: fit-content, so next to an edge it shrinks against it and measuring the width after positioning gives a value that is too small. The width is therefore measured only after moving the element away from the edge — without that, the right side still touched the screen edge.Verification
Browser measurements on the
Interactivestory, 320 px viewport:left: -170left: 8,right: 312left: -76.5left: 8,right: 312right: 320(no gutter)left: 8,right: 312Arrow offset from the trigger centre: 0 px in every case. Desktop (1280 px) is unchanged —
max-width: 900px, tooltip centered,shift = 0.yarn lint,yarn format:check,yarn ts:checkall clean.yarn test— 762 tests across 56 files, all passing.