Skip to content

Commit

Permalink
Don't include window scrollbars in the space available for tooltips
Browse files Browse the repository at this point in the history
FIX: Don't include the window scrollbars in the space available for displaying
tooltips.

Closes codemirror/dev#1512
  • Loading branch information
marijnh committed Jan 27, 2025
1 parent 22860a1 commit 4bdec39
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,10 @@ export function tooltips(config: {
parent?: HTMLElement
/// By default, when figuring out whether there is room for a
/// tooltip at a given position, the extension considers the entire
/// space between 0,0 and `innerWidth`,`innerHeight` to be available
/// for showing tooltips. You can provide a function here that
/// returns an alternative rectangle.
/// space between 0,0 and
/// `documentElement.clientWidth`/`clientHeight` to be available for
/// showing tooltips. You can provide a function here that returns
/// an alternative rectangle.
tooltipSpace?: (view: EditorView) => Rect
} = {}): Extension {
return tooltipConfig.of(config)
Expand All @@ -118,8 +119,8 @@ type TooltipConfig = {
}

function windowSpace(view: EditorView) {
let {win} = view
return {top: 0, left: 0, bottom: win.innerHeight, right: win.innerWidth}
let docElt = view.dom.ownerDocument.documentElement
return {top: 0, left: 0, bottom: docElt.clientHeight, right: docElt.clientWidth}
}

const tooltipConfig = Facet.define<Partial<TooltipConfig>, TooltipConfig>({
Expand Down

0 comments on commit 4bdec39

Please sign in to comment.