Skip to content

Safari: regaining focus after scrolling and defocusing causes strange behavior #1626

@emfrosztovis

Description

@emfrosztovis

Describe the issue

  • Use the minimal editor in the sandbox, put a lot of text in it
  • Click to put the cursor anywhere; or make a selection, it's the same
  • Scroll so that the cursor is outside of the visible edit area (let's call this view X)
  • Defocus the editor, e.g. by clicking outside it
  • Focus on the editor again by clicking inside it (let's call the clicked point A)

Expectation:

  • The editor stays in view X
  • The cursor moves to the character at A (in view X)

Result:

  • The editor instantly scrolls back to somewhere near where the cursor originally was (let's call this view Y)
  • A selection is formed between: the character at A in view X, and the character at A in view Y

Additionally, selection rendering is frequently broken in Safari (maybe a browser bug). Generally you can see it after first playing around with selection for a while then clicking to clear the selection. This also seems to occur more with some text than other. I'm not sure how to reproduce it reliably so I'm not creating another issue for now, but this happens very often for me.

Browser and platform

Safari 26

Reproduction link

https://codemirror.net/try/#example=Minimal%20editor

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