Android selection drag handle gets stuck #1675

Open
opened 2026-02-15 22:01:10 +01:00 by lishid · 8 comments
lishid commented 2026-02-15 22:01:10 +01:00 (Migrated from github.com)

Describe the issue

When dragging the drag handle to select text, sometimes it gets "stuck" and can't be moved anymore. Seems to happen more often if you move the drag handle quickly.

https://github.com/user-attachments/assets/4b2c2a44-2f4d-4f3e-805f-91ec7c221dc0

Browser and platform

Android 16 / Chrome 145.0.7632.75

https://codemirror.net/try/

### Describe the issue When dragging the drag handle to select text, sometimes it gets "stuck" and can't be moved anymore. Seems to happen more often if you move the drag handle quickly. https://github.com/user-attachments/assets/4b2c2a44-2f4d-4f3e-805f-91ec7c221dc0 ### Browser and platform Android 16 / Chrome 145.0.7632.75 ### Reproduction link https://codemirror.net/try/
marijnh commented 2026-02-16 12:07:51 +01:00 (Migrated from github.com)

I can reproduce this. It seems to be related to highlightSelectionMatches causing DOM changes around the selection (adding the wrapper nodes that do the highlighting), which somehow causes Chrome to decide the drag needs to be aborted. The only solution I was able to find was to turn off highlightSelectionMatches.

I can reproduce this. It seems to be related to `highlightSelectionMatches` causing DOM changes around the selection (adding the wrapper nodes that do the highlighting), which somehow causes Chrome to decide the drag needs to be aborted. The only solution I was able to find was to turn off `highlightSelectionMatches`.
lishid commented 2026-02-16 15:50:51 +01:00 (Migrated from github.com)

We're experiencing something similar (although not using highlightSelectionMatches) in Obsidian where selecting in a long document with heavy formatting causes the drag to be aborted almost every paragraph, which makes selecting large parts of the document really difficult. If I remember correctly we are already detecting that this drag has started and we stop making any decoration changes during a drag.

Do you have any suggestion on how we can isolate the cause on our side?

We're experiencing something similar (although not using highlightSelectionMatches) in Obsidian where selecting in a long document with heavy formatting causes the drag to be aborted almost every paragraph, which makes selecting large parts of the document really difficult. If I remember correctly we are already detecting that this drag has started and we stop making any decoration changes during a drag. Do you have any suggestion on how we can isolate the cause on our side?
marijnh commented 2026-02-16 16:06:27 +01:00 (Migrated from github.com)

By 'isolate' you mean find out which decoration is triggering this? I guess you could turn off extensions one by one to see which one(s) affect this problem.

By 'isolate' you mean find out which decoration is triggering this? I guess you could turn off extensions one by one to see which one(s) affect this problem.
lishid commented 2026-02-16 16:33:22 +01:00 (Migrated from github.com)

You're right, I should have thought of that. Will report back.

You're right, I should have thought of that. Will report back.
lishid commented 2026-02-16 19:02:18 +01:00 (Migrated from github.com)

So far I've isolated the problem to multiple extensions. One of the offenders was an active line highlighter which added .cm-active to the currently selected line (which got updated as the selection changed).

But even disabling it I found that just having block widgets in general will cause the issue to happen from time to time when the selection crosses over the block widget.

Repro link

https://github.com/user-attachments/assets/ca9250db-9b84-4afb-91da-dd5e828447af

So far I've isolated the problem to multiple extensions. One of the offenders was an active line highlighter which added `.cm-active` to the currently selected line (which got updated as the selection changed). But even disabling it I found that just having block widgets in general will cause the issue to happen from time to time when the selection crosses over the block widget. [Repro link](https://codemirror.net/try/#c=aW1wb3J0IHtXaWRnZXRUeXBlLCBEZWNvcmF0aW9uLCBFZGl0b3JWaWV3fSBmcm9tICJAY29kZW1pcnJvci92aWV3IgppbXBvcnQge1N0YXRlRmllbGR9IGZyb20gIkBjb2RlbWlycm9yL3N0YXRlIgpjbGFzcyBUZXN0V2lkZ2V0IGV4dGVuZHMgV2lkZ2V0VHlwZSB7CiAgdG9ET00oKSB7CiAgICBsZXQgZWwgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCdkaXYnKTsKICAgIGVsLmlubmVySFRNTCA9ICc8YnI+JzsKICAgIHJldHVybiBlbDsKICB9Cn0KbmV3IEVkaXRvclZpZXcoewogIGRvYzogImNvbnNvbGUubG9nKCdoZWxsbycpXG4iLnJlcGVhdCg1KSwKICBleHRlbnNpb25zOiBbU3RhdGVGaWVsZC5kZWZpbmUoewogICAgY3JlYXRlKCkgeyAKICAgICAgcmV0dXJuIERlY29yYXRpb24uc2V0KFsKICAgICAgICBEZWNvcmF0aW9uLndpZGdldCh7d2lkZ2V0OiBuZXcgVGVzdFdpZGdldCgpLCBibG9jazogdHJ1ZX0pLnJhbmdlKDQyKQogICAgICBdKTsKICAgIH0sCiAgICB1cGRhdGUoZGVjb3MsIHRyKSB7CiAgICAgIHJldHVybiBkZWNvczsKICAgIH0sCiAgICBwcm92aWRlOiBmID0+IEVkaXRvclZpZXcuZGVjb3JhdGlvbnMuZnJvbShmKQogIH0pXSwKICBwYXJlbnQ6IGRvY3VtZW50LmJvZHkKfSkK) https://github.com/user-attachments/assets/ca9250db-9b84-4afb-91da-dd5e828447af
lishid commented 2026-02-19 16:43:16 +01:00 (Migrated from github.com)

Were you able to reproduce it with the block widgets? I can remove the line highlighter for Android, but I don't really have a good workaround for block widgets...

Were you able to reproduce it with the block widgets? I can remove the line highlighter for Android, but I don't really have a good workaround for block widgets...
marijnh commented 2026-02-19 16:54:57 +01:00 (Migrated from github.com)

Nope. I tried to get highlightSelectionMatches to stop changing the DOM during selection, but it appears a script cannot even really detect that that is happening, since no touch events are fired for selection handle dragging.

So I think all I can do here is call this a browser issue. You could try to set up a small script without CodeMirror that displays the problem, and report it to the Blink team.

Nope. I tried to get `highlightSelectionMatches` to stop changing the DOM during selection, but it appears a script cannot even really detect that that is happening, since no touch events are fired for selection handle dragging. So I think all I can do here is call this a browser issue. You could try to set up a small script without CodeMirror that displays the problem, and report it to the Blink team.
lishid commented 2026-02-19 16:59:57 +01:00 (Migrated from github.com)

Ah that's unfortunate. We internally were able to debounce on selection change to block all widget changes while the selection was rapidly changing, and flush later. This works for our active line highlighter widget, but it seems that selection still gets stuck on random occasions when crossing block widgets.

Ah that's unfortunate. We internally were able to debounce on selection change to block all widget changes while the selection was rapidly changing, and flush later. This works for our active line highlighter widget, but it seems that selection still gets stuck on random occasions when crossing block widgets.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
codemirror/dev#1675
No description provided.