Skip to content

Commit

Permalink
Fix logic for detecting broken fixed positioning
Browse files Browse the repository at this point in the history
FIX: Fix an issue where, on Chrome, tooltips would no longer use fixed positioning.

See https://discuss.codemirror.net/t/tooltip-positioning-as-fixed-vs-absolute-in-latest-updates/7104/7
Issue codemirror/dev#1262
  • Loading branch information
marijnh committed Sep 22, 2023
1 parent a484959 commit 0c40c05
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,13 +233,13 @@ const tooltipPlugin = ViewPlugin.fromClass(class {
readMeasure(): Measured {
let editor = this.view.dom.getBoundingClientRect()
let scaleX = 1, scaleY = 1, makeAbsolute = false
if (this.position == "fixed") {
let views = this.manager.tooltipViews
// When the dialog's offset parent isn't the body, we are
// probably in a transformed container, and should use absolute
// positioning instead, since fixed positioning inside a
// transform works in a very broken way.
makeAbsolute = views.length > 0 && views[0].dom.offsetParent != this.container.ownerDocument.body
if (this.position == "fixed" && this.manager.tooltipViews.length) {
// When the dialog's offset parent isn't the body (Firefox) or
// null (Webkit), we are probably in a transformed container,
// and should use absolute positioning instead, since fixed
// positioning inside a transform works in a very broken way.
let {offsetParent} = this.manager.tooltipViews[0].dom
makeAbsolute = !!(offsetParent && offsetParent != this.container.ownerDocument.body)
}
if (makeAbsolute || this.position == "absolute") {
if (this.parent) {
Expand Down

0 comments on commit 0c40c05

Please sign in to comment.