Skip to content

Commit 4bdec39

Browse files
committed
Don't include window scrollbars in the space available for tooltips
FIX: Don't include the window scrollbars in the space available for displaying tooltips. Closes codemirror/dev#1512
1 parent 22860a1 commit 4bdec39

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/tooltip.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,10 @@ export function tooltips(config: {
103103
parent?: HTMLElement
104104
/// By default, when figuring out whether there is room for a
105105
/// tooltip at a given position, the extension considers the entire
106-
/// space between 0,0 and `innerWidth`,`innerHeight` to be available
107-
/// for showing tooltips. You can provide a function here that
108-
/// returns an alternative rectangle.
106+
/// space between 0,0 and
107+
/// `documentElement.clientWidth`/`clientHeight` to be available for
108+
/// showing tooltips. You can provide a function here that returns
109+
/// an alternative rectangle.
109110
tooltipSpace?: (view: EditorView) => Rect
110111
} = {}): Extension {
111112
return tooltipConfig.of(config)
@@ -118,8 +119,8 @@ type TooltipConfig = {
118119
}
119120

120121
function windowSpace(view: EditorView) {
121-
let {win} = view
122-
return {top: 0, left: 0, bottom: win.innerHeight, right: win.innerWidth}
122+
let docElt = view.dom.ownerDocument.documentElement
123+
return {top: 0, left: 0, bottom: docElt.clientHeight, right: docElt.clientWidth}
123124
}
124125

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

0 commit comments

Comments
 (0)