fix(a11y): add collision-aware placement to Tooltip#138
Merged
mikewheeleer merged 3 commits intoJun 25, 2026
Conversation
Contributor
|
nice work — thanks for this! |
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.
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