From 4bdec391ac18301e2fdc1f6bd0daca65d7862f40 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 27 Jan 2025 10:57:18 +0100 Subject: [PATCH] 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 https://github.com/codemirror/dev/issues/1512 --- src/tooltip.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/tooltip.ts b/src/tooltip.ts index 50ce3b2..7b262f9 100644 --- a/src/tooltip.ts +++ b/src/tooltip.ts @@ -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) @@ -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, TooltipConfig>({