Skip to content

Tooltip positioning does not take page scroll into account in Firefox #84

@thibaudcolas

Description

@thibaudcolas

In Firefox, the position of the link/document inline tooltip does not take page scrolling into account:

draftail-tooltip-position

Reported in Firefox (54.0.1) but might also affect other browsers. Works in Chrome at least. This is reproducible with vanilla Draftail on https://www.draftail.org/.

This is most likely a cross-browser difference in the behavior of the DOM APIs used to make the calculation, at https://github.com/springload/draftail/blob/v0.7.3/lib/components/DraftailEditor.js#L481:

position={{
    top: this.tooltip.getBoundingClientRect().top + document.body.scrollTop + this.tooltip.offsetHeight,
    left: this.tooltip.getBoundingClientRect().left + document.body.scrollLeft,
}}

I'm not entirely sure what is wrong with the calculation as-is, this will need troubleshooting. The solution would most likely align with what http://youmightnotneedjquery.com/ does (search for "offset"), or https://github.com/timoxley/offset/blob/master/index.js#L49.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomershelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions