Summary:
Comment tooltip mis-positioned when Hot inside scrolling region/DIV
I have a Hot with comments
enabled. The page has some scrolling <DIV>
region, inside which everything including the Hot is placed. Note that it is not the Hot, nor the page/body, itself which has scrolling (that may or may not work, not my situation).
See https://jsfiddle.net/vdow00w1/ for a simple example.
Detail:
When you initially hover over the comment in cell (4,4) the tooltip is correctly placed next to that cell. But if you scroll the enclosing DIV
the tooltip stays in exactly the same position relative to the page, whereas it should be relative to the cell. In this particular case that is not the end of the world, but in more complex example it actually gets placed below very bottom left corner of the page, causing redrawing & flickering and being inaccessible.
I have had a look at code and handsontable.full.js
. The tooltip is positioned with position: absolute
. Calculation of coordinates is in refreshEditorPosition
. I think the problem may come from var cellOffset = offset(TD);
. function offset()
does some kind of walking up the container hierarchy till it reaches document.body
looking at offsets, and does something if body’s child is position: fixed
. But I do not see it taking into account a scrolled DIV
ancestor, as you have to whenever using position: absolute
?
The code in refreshEditorPosition
looks too scary for me to understand (e.g. it looks at getBoundingRect()
to decide whether to hide the tooltip depending on its location, and I’m not sure whether that is right/what coordinates it uses).
Is there anything I can do myself to rectify this problem? For example, if there was any positioning style I could place on the scrolled ancestor DIV
I might consider that, but I did not see anything in my investigations.
Thanks in advance.
P.S.
FWIW, the Context Menu also uses position: absolute
but is not confused/mis-positioned when inside a scrolled DIV. I think it gets its position right via pageY(event)
, so off the mouse pointer coordinates of the right-click. But I guess that is not suitable for a comment’s tooltip, as that needs to find the cell is comment is in?