Skip to content

Commit

Permalink
Properly include arrow height when checking for tooltip space
Browse files Browse the repository at this point in the history
FIX: Properly include the tooltip arrow height when checking whether a tooltip
fits in its preferred above/below position.

See https://discuss.codemirror.net/t/issues-with-tooltip-above-below-calculation/8779
  • Loading branch information
marijnh committed Nov 8, 2024
1 parent e30c4ca commit 869252a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,8 @@ const tooltipPlugin = ViewPlugin.fromClass(class {
: Math.min(Math.max(space.left, pos.left - width + (arrow ? Arrow.Offset : 0) - offset.x), space.right - width)
let above = this.above[i]
if (!tooltip.strictSide && (above
? pos.top - (size.bottom - size.top) - offset.y < space.top
: pos.bottom + (size.bottom - size.top) + offset.y > space.bottom) &&
? pos.top - height - arrowHeight - offset.y < space.top
: pos.bottom + height + arrowHeight + offset.y > space.bottom) &&
above == (space.bottom - pos.bottom > pos.top - space.top))
above = this.above[i] = !above
let spaceVert = (above ? pos.top - space.top : space.bottom - pos.bottom) - arrowHeight
Expand Down

0 comments on commit 869252a

Please sign in to comment.