text selection grabbers no longer show on iOS (18.3.1) since 6.35.1 #1538
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Describe the issue
I noticed the lack of 'grabbers'/'handles' for my text selections on my iPhone after recently upgrading and could pinpoint the problem to changes in @codemirror/view version 6.35.1; when using 6.35.0 they still show beautifully. Now they have completely disappeared (in all versions after 6.35.0), which makes for a poorer UI.
What I get with @codemirror/view 6.35.1 onwards:

What I got with @codemirror/view 6.35.0 and earlier (and what I think it is supposed to look like):

Browser and platform
mobile Safari on iOS 18.3.1
Reproduction link
https://codemirror.net/try/
It appears that the selection handles are affected by the
caret-colorstyle, which we're setting to transparent because we draw our own cursor and don't want the native cursor to interfere.My initial attempt to handle this was to set it back to
initialwhen there is a non-cursor selection but unfortunately, mobile Safari being the pile of hacks that it is, it appears to only query this style once, when the selection is made (at which point it is still transparent) and then keeps using that color for the lifetime of the non-empty selection, instead of properly querying the current style. This makes it somewhat hard to control this.I'll see if I can find a kludge, but so far it looks difficult.
Ouch. That sounds painful indeed.
Thank you for looking into this and for your explanation of how this came to be and why it is difficult to restore the mobile selection behaviour that I got used to. I would not know where to start finding a solution/workaround either I'm afraid.
@marijnh Would a viable solution be to just draw custom cursors on both ends of the range selection? They could be enabled only for mobile Safari and styled to look like the native ones with the circle on top or bottom.
I think it makes sense to maintain fully custom cursors if using the
drawSelectionextension, rather than a half custom, half native solution depending on if the selection is a range or not.The thing is that, if we draw them as part of the selection layer, which is easy, they'll be clipped off at the edge of the editor by the regular CSS rules and won't be able to stick out of the editor like the native handles would. Also, transparent line backgrounds and such will affect them.
Drawing them as overlays over the editor would be possible, but involve a lot more complexity to ensure they stay properly aligned to the selection.
I'm still half-expecting there to be some undocumented prefixed CSS property that allows us to style these separate from the caret color, but I haven't been able to find such a thing.
caret-shapeis a brand new thing https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/caret-shape but I don't expect it to be of much help here.Is there some kind of "force a repaint" strategy we could look at?
Is there any situation in which iOS selections do not have selection handles? I know on Android this is a thing, but I couldn't create a situation like that in Mobile Safari.
If not, I guess drawing our own is unproblematic, since these seem to generally be small enough to not stick out of the editor. Attached patch does this (it's in a branch for now). Can anyone think of any issues with this?
I'm not aware of any situations where the drag handles wouldn't be shown. Even on regular text in a page the handles are shown, so readonly instances should also have them (IMO). Not opposed to drawing them within CodeMirorr, though it's nice to use native if it's available.
We were testing our own workaround for this that primarily involved just restoring the
caret-coloron ahover: nonemedia query. Thecaret-color: transparentoverrides within CM6 seem to be super high precedence & specificity, so I had to force it like this.The styles could maybe be more targeted to iOS, but does CodeMirror have that kind of detection built into the Theming or would it need to be a
ViewPluginof some sort?Is
hover:nonejust targeting touch platforms? Unhiding the cursor in general on such platforms is not a good idea, when you're usingdrawSelection. You'll see two cursors in some situations, and messy overlapping cursors in others.Yes,
hover: noneis primarily touch devices. I haven't tested multi-cursor with it (not sure how to do that on touch), but it seems to be working as expected.Is there an easy way to test the changes in
github.com/codemirror/view@223fe91207? Even on codemirror.net/try or something.They are in @codemirror/view version 6.39.16
Hm. Doesn't look like the changes from https://github.com/codemirror/view/tree/ios-selection-handles were merged into main for 6.39.16.
Oh right, I put it in a branch, sorry. The easiest way to test this would be to clone the repository, check out that branch, build it (
npm install), and then copy the files indistinto your project'snode_modules/@codemirror/view/dist. Don't just link in the package, since that will also link in its localnode_modules.Hi, a quick question on these new selection handles for iOS - will it be possible to enable/disable them?
I've also implemented my own iOS selection handles and maybe they might interfere with them...
I mean, the idea would be that you no longer have to implement your own selection handles. But I guess an option to disable them is easy to add. See attached patch (which is on the main branch now).
Great, thanks!
Since I have already implemented them (using ViewPlugin, Decoration and WidgetType) and they are working great and also offering also some specific features (like custom dragging, scroll-control), I want/need to keep them.
My plan was also to release them later as free Codemirror extension.