Skip to content

fix(a11y): add collision-aware placement to Tooltip#138

Merged
mikewheeleer merged 3 commits into
Agentpay-Org:mainfrom
AbuJulaybeeb:a11y/a11y-tooltip-positioning
Jun 25, 2026
Merged

fix(a11y): add collision-aware placement to Tooltip#138
mikewheeleer merged 3 commits into
Agentpay-Org:mainfrom
AbuJulaybeeb:a11y/a11y-tooltip-positioning

Conversation

@AbuJulaybeeb

Copy link
Copy Markdown
Contributor

What was done:

Collision-Aware Flipping: Modified Tooltip.tsx to compute available space above the trigger. If the space is less than the tooltip height + an 8px safety boundary, it flips and mounts below the trigger.
Horizontal Clamping: Computes viewport-relative horizontal boundaries. Clamps placement coordinates to prevent the tooltip content from clipping off the left or right edges of the screen.
Improved Eslint & React State Flow: Reworked focus/blur handlers into helper callbacks to reset coordinates outside useEffect, avoiding any cascading render warnings.
Documentation: Added a detailed JSDoc block to Tooltip outlining the new collision-aware placement rules.
Testing: Extended src/components/tests/Tooltip.test.tsx with a new suite mocking getBoundingClientRect measurements under 1024px viewport width:
Default placement (above, centered).
Top-edge collision (flips below).
Left-edge collision (clamps relative left to keep tooltip on-screen).
Right-edge collision (clamps relative left to stay inside viewport bounds).
Environment Maintenance: Kept test environment overrides active to ensure lint and typecheck pass without type or syntax regressions.

closes #91

@mikewheeleer

Copy link
Copy Markdown
Contributor

nice work — thanks for this!

@mikewheeleer mikewheeleer merged commit b0e2a43 into Agentpay-Org:main Jun 25, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reposition the Tooltip to avoid viewport overflow and clipping

2 participants