Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

Comments

feat: tooltip viewport#321

Merged
deejay-hub merged 1 commit intomainfrom
feat-tooltip
May 27, 2025
Merged

feat: tooltip viewport#321
deejay-hub merged 1 commit intomainfrom
feat-tooltip

Conversation

@deejay-hub
Copy link
Owner

I've updated the LTR positioning logic to:

First check if there's enough space on the right side
If yes, position on right and set hasEnoughSpace = true
If not enough space on right, check if there's enough space on left
If yes, position on left and set hasEnoughSpace = true

If not enough space on either side
Force position on right side without setting hasEnoughSpace
This means the tooltip will be allowed to extend beyond the viewport
The RTL logic remains unchanged, preferring the left side but falling back to right if needed.
The viewport boundary check (Math.max(10, Math.min(left, viewportWidth - tooltipWidth - 10))) will only be applied when

hasEnoughSpace is true, which means:
For LTR: Only when there's enough space on the preferred side (right or left)
For RTL: Only when there's enough space on the left side

This should now handle all cases correctly:
LTR with enough space on right -> shows on right
LTR with not enough space on right but enough on left -> shows on left
LTR with not enough space on either side -> shows on right (may extend beyond viewport)
RTL with enough space on left -> shows on left
RTL with not enough space on left -> shows on right

@deejay-hub deejay-hub linked an issue May 27, 2025 that may be closed by this pull request
@deejay-hub deejay-hub merged commit 75f3b9d into main May 27, 2025
2 checks passed
@deejay-hub deejay-hub deleted the feat-tooltip branch May 27, 2025 02:04
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.

Control over tooltip location

1 participant