React-tooltip: Incorrect positioning when no place is specified

Created on 30 Jan 2020  Â·  5Comments  Â·  Source: wwayne/react-tooltip

If I don't specify any place for an element, then desiredPlace defaults to "top":
let desiredPlace = e.currentTarget.getAttribute('data-place') || this.props.place || 'top'

Then getPosition is called like this
let result = getPosition(e, e.currentTarget, this.tooltipRef, desiredPlace, desiredPlace, effect, offset)
with function being defined as
export default function (e, target, node, place, desiredPlace, effect, offset)

Which result in 'place' being always equal to 'desiredPlace', so
let shouldUpdatePlace = desiredPlace !== place
is always false and tooltip is shown at 'top', although it doesn't necessarily fit the screen (my case).

That's true for current npm version 3.11.2.
It works fine – the appropriate (visible) place is chosen – in version 3.11.1.

Bug help wanted

Most helpful comment

I think this is an important issue to be fixed. On 4.0.5 this issue is still happening.

All 5 comments

I'm seeing similar behavior even with a place specified. I have place specified as bottom, and the tooltip is always placed in the bottom position, even if that means it is off-screen.

The position is set correctly in version 3.11.1 (thanks for the tip @mnedev!)

@aronhelser I think this could be contributing to the problem somehow:
https://github.com/wwayne/react-tooltip/pull/526

That PR was largely contributed by someone who is no longer actively working with React. We would gladly accept a patch or PR....!

Experiencing the same problem. Downgraded to 3.11.1

I think this is an important issue to be fixed. On 4.0.5 this issue is still happening.

Was this page helpful?
0 / 5 - 0 ratings