Skip to content

Autocomplete tooltip invisible when using EditorView.scrollMargins #1689

@krpano

Description

@krpano

Describe the issue

There is a positioning conflict between the autocompletion tooltip and EditorView.scrollMargins. When typing a character (e.g. 'f') at the very beginning of a document, the autocomplete menu is initialized but remains invisible.

Testcase:

Steps to Reproduce:

  • Use EditorView.scrollMargins with a significant margin (e.g. 100px).
  • Start with an empty JavaScript document.
  • Type a single character (like 'f') in the first line.
  • The cursor becomes "trapped" (arrow up/down keys stop working) because the autocomplete keymap is active, but the menu is positioned far off-screen.

Expected Behavior:

  • The tooltip should be positioned correctly at the cursor, even if the cursor is within the defined scrollMargins.

Observed Behavior:

  • The tooltip is invisible (css top position of -10000px).
  • The cursor is trapped, up/down keys do not to work.
  • Pressing ESC closes the invisible menu and restores normal cursor movement.
  • Occurs when scrollMargins are larger than the distance from the cursor to the editor edge.

Environment:

  • CodeMirror 6
  • @codemirror/view (latest)
  • @codemirror/autocomplete (latest)

Browser and platform

No response

Reproduction link

https://codemirror.net/try/#c=aW1wb3J0IHtiYXNpY1NldHVwLCBFZGl0b3JWaWV3fSBmcm9tICJjb2RlbWlycm9yIgppbXBvcnQge2phdmFzY3JpcHR9IGZyb20gIkBjb2RlbWlycm9yL2xhbmctamF2YXNjcmlwdCIKaW1wb3J0IHthdXRvY29tcGxldGlvbn0gZnJvbSAiQGNvZGVtaXJyb3IvYXV0b2NvbXBsZXRlIgoKbmV3IEVkaXRvclZpZXcoewogIGRvYzoKICAgICIvLyBzY3JvbGxNYXJnaW5zIHRvb2x0aXBzIGJ1ZzpcbiIrCiAgICAiLy8gdHlwZSAnZicgaW4gdGhlIG5leHQgbGluZSwgdGhlIGF1dG9jb21wbGV0aW9uIHRvb2x0aXAgc2hvdWxkIGFwcGVhcjpcbiIsCiAgZXh0ZW5zaW9uczogWwogICAgYmFzaWNTZXR1cCwKICAgIGphdmFzY3JpcHQoKSwKICAgIGF1dG9jb21wbGV0aW9uKCksCiAgICBFZGl0b3JWaWV3LnNjcm9sbE1hcmdpbnMub2YoKHZpZXcpID0+IHsKICAgICAgcmV0dXJuIHsgbGVmdDogMTAwLCB9CiAgICB9KQogIF0sCiAgcGFyZW50OiBkb2N1bWVudC5ib2R5Cn0pCg==

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions