Custom tooltip position is not maintained at top of cursor

Hi @marijn ,

I am generating custom tooltip using the below code snippet:

 const cursorTooltipField = StateField.define<readonly Tooltip[]>({
        create: getCursorTooltips,

        update(tooltips, tr) {
            if (!tr.docChanged && !tr.selection) return tooltips;
            return getCursorTooltips(tr.state);

        provide: (f) => showTooltip.computeN([f], (state) => state.field(f)),

I am also using autocomplete feature to generate suggestions while user is typing. However, I am facing an issue where tooltip’s position is not always at top of cursor in the editor. See below gif:


Is there a way to fix this issue by always keeping tooltip on top of cursor, if tooltip exists there ?

The above and strictSide properties on your tooltip control where it is rendered. If the tooltip content changes size due to some kind of asynchronous rendering after being returned, that might also mess with this.