You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to get the offsetWidth of the element to properly adjust the position of the tooltip depending on the length of the text. But the overridePosition call happens twice for showTooltip and updatePosition. Where it gives me the incorrect offsetWidth the second time.
This is what it gives me using currentTarget.offsetWidth in overridePosition callback.
overridePosition={({ left, top },_currentEvent,currentTarget)=>{console.log('currentTarget',currentTarget.offsetWidth);if(position==='left'){left=left+currentTarget.offsetWidth*0.25;}if(position==='right'){left=left-currentTarget.offsetWidth*0.25;}return{ top, left };}}
The workaround I did to get the correct offsetWidth.
overridePosition={({ left, top })=>{// Gets the element's width to be used to adjust the positioning of// the tooltip dependent on the Popover position propconstelement=document.getElementById(id||uid);consttooltipWidth=element ? element.offsetWidth : 0;if(position==='left'){left=left+tooltipWidth*0.25;}if(position==='right'){left=left-tooltipWidth*0.25;}return{ top, left };}}
The text was updated successfully, but these errors were encountered:
finikwashere
pushed a commit
to finikwashere/react-tooltip
that referenced
this issue
Feb 5, 2020
I'm trying to get the
offsetWidth
of the element to properly adjust the position of the tooltip depending on the length of the text. But theoverridePosition
call happens twice forshowTooltip
andupdatePosition
. Where it gives me the incorrect offsetWidth the second time.https://github.com/wwayne/react-tooltip/blob/ccb8b58a6762f3393f7d71c157c64ae24a81674c/src/index.js#L313-L314
https://github.com/wwayne/react-tooltip/blob/ccb8b58a6762f3393f7d71c157c64ae24a81674c/src/index.js#L489-L490
This is what it gives me using
currentTarget.offsetWidth
inoverridePosition
callback.The workaround I did to get the correct offsetWidth.
The text was updated successfully, but these errors were encountered: