Skip to content

Commit

Permalink
Support offset/getCoords/overlap/resize on hover tooltips
Browse files Browse the repository at this point in the history
FIX: Support the `offset`, `getCoords`, `overlap`, and `resize` properties
on hover tooltips, as long as they aren't given conflicting values when there are
multiple active hover tooltips.

See https://discuss.codemirror.net/t/multiple-hovertooltips/7201/3
  • Loading branch information
marijnh committed Oct 11, 2023
1 parent ad41f81 commit b75e075
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,26 @@ class HoverTooltipHost implements TooltipView {
destroy() {
for (let t of this.manager.tooltipViews) t.destroy?.()
}

passProp<Key extends keyof TooltipView>(name: Key): TooltipView[Key] | undefined {
let value: TooltipView[Key] | undefined = undefined
for (let view of this.manager.tooltipViews) {
let given = view[name]
if (given !== undefined) {
if (value === undefined) value = given
else if (value !== given) return undefined
}
}
return value
}

get offset() { return this.passProp("offset") }

get getCoords() { return this.passProp("getCoords") }

get overlap() { return this.passProp("overlap") }

get resize() { return this.passProp("resize") }
}

const showHoverTooltipHost = showTooltip.compute([showHoverTooltip], state => {
Expand Down

0 comments on commit b75e075

Please sign in to comment.