New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 617981 link

Starred by 2 users

Issue metadata

Status: Available
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 3
Type: Feature

Blocking:
issue 463348



Sign in to add a comment

Add a mechanism for knowing when text selection changes have ended

Reported by krinklem...@gmail.com, Jun 7 2016

Issue description

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.94 Safari/537.36

Example URL:
http://s.codepen.io/Krinkle/debug/JKYOpV

Steps to reproduce the problem:
1. Put the cursor in a contenteditable element in Chromium on Android.
2. Move the cursor around in the document (not extending but moving the cursor itself by dragging the single blue dot).

Example: http://s.codepen.io/Krinkle/debug/JKYOpV

What is the expected behavior?
As a developer, I should be able to render a menu when the user isn't actively changing their selection.

The native Android interface does this for the copy/paste menu, which doesn't show as long as the user's finger is on the screen and appears as soon as the user releases their finger from the screen.

What went wrong?
Chrome only emits 'selectionchange' events. There are no touchstart, touchmove, or touchend events being emitted. As such there appears to be no way to reliably determine that the user is "done" (e.g. implement the same kind of menu hiding/showing as Chrome does natively).

On Mobile Safari, there are touchstart, touchmove and touchend events emitted (in addition to the 'selectionchange' events). Which allows me to use 'touchend' to decide whether to change the menu appearance.

Chrome however is missing these touch events when changing selection.

In some use cases a debounced event handler based on selectionchange might work, but depending on the design of the interface this is not an option. For example, imagine a scenario where the "selection done" handler will result in the interface changing in a way that makes the text move down or up to make room for an interface component. This is distracting and confusing to the user and should not happen as long as their finger is still on the text.

Does it occur on multiple sites: Yes

Is it a problem with a plugin? No 

Did this work before? N/A 

Does this work in other browsers? Yes 

Chrome version: 50.0.2661.94  Channel: canary
OS Version: OS X 10.11.4
Flash Version:
 

Comment 1 by ebra...@gnu.org, Jun 7 2016

Blocking: 463348
Components: -Blink Blink>Input
Labels: -Type-Bug Type-Feature
Labels: -Type-Feature Type-Bug
Sorry, going back to "Type-Bug" to let the input team decide if this is a feature request or bug. Feature requests may not show up in triage searches.
Cc: dtapu...@chromium.org chongz@chromium.org tdres...@chromium.org mustaq@chromium.org
Labels: -Pri-2 -OS-Mac Hotlist-Input-Dev OS-Android Pri-3
Owner: rbyers@chromium.org
Status: Assigned (was: Unconfirmed)
rbyers@; I'm assigning this to you so you can comment on the interoperability of this with in the touch events spec space.

I do see equivalence of this with mousemoves being fired during text selection.
Cc: aelias@chromium.org
This is an interesting use case, thanks!  I definitely agree with the big picture that it should be possible to augment text selection behavior in JavaScript.  In general editing (and touch text selection in particular) is known to have a big problem with not being inline with the extensible web (https://github.com/extensibleweb/manifesto).

My initial reaction was to say: "sure, if Safari is doing this we should just match".  But I've spent some time playing with Safari and it's not quite so simple.

It looks like when you're dragging the carat around (the UI with the circular magnifying lense) you do indeed get touch events.  But if you double-tap on a word to select it and then try dragging one of those handles, you appear to get selectionchange without the touch events.  That's still a problem for you, right?

This design makes sense to me - for a gesture that starts by touching anywhere on the page, the page gets to see the entire event stream.  But if the user touches on a UI element (like a selection handle) that's floating over TOP of the page, then the entire event sequence is hidden from the page.  I think Chrome and Safari are consistent on this design point (while matching their host OS's difference in selection UX).

The other problem here is what should be done if the touch events are canceled.  If you call preventDefault on such a touchmove, should it prevent the handle from dragging?  That would probably be unacceptable from a performance perspective (would make handle dragging tied to the JS thread).  So maybe instead we could treat this similarly to scrolling: once dragging starts the touchmove events have cancelable=false.

There's some risk of double-handling behavior here (eg. user is trying to move a selection handle but a carousel is sliding under their finger in response to the touchmove events, making it impossible to correctly position the handle).  But that's a potential problem with scrolling today too and is generally addressed by cancelling the touchstart or first touchmove event.  To support passive touch listeners, we might also need to disable selection over elements where scrolling has been disabled with touch-action (or, ugh, worst-case add new touch-action keywords for controlling selection).

So this would basically be a model where selection dragging was the default action of the first touchmove.  The page would always get first crack at the events ("content not chrome" FTW!) and if canceled, the user couldn't drag the handle.  The problem with this is that for the cases where it's not the intended UX (eg. selectable text inside of a swipable carousel), there's no good way for the developer to give priority to selection (there's no API to indicate that the touch actually occurred over a handle).  I think that kills this idea :-(

I see two other options:

1) Fire touch events at the 'window' in this case.  I.e. the handle still occludes the HTML underneath, so touches can't actually hit any DOM elements.  But the conceptually still "bubble" up to the containing window which holds the handles.  These could probably be strictly uncancelable (though maybe it would also be fine to allow the app to prevent handle dragging if it was really listening on the window).

2) Stop trying to use touch events for this and instead extend the selection APIs.  Eg. maybe the selectionchange event should have an "inProgress" boolean on it which is true while a change is actively happening, and false on the last event in a sequence (which I guess might not actually change the selection at all).  Or there could just be a simple "selectionchangeend" event.

Thoughts?
Labels: -Type-Bug Type-Feature
Summary: Add a mechanism for knowing when touch text selection has ended (was: Missing touch events for selectionchange on mobile)
Cc: amaralp@chromium.org
I like 2) "inProgress"/"selectionchangeend" event proposal.  If we add it, we should also make it work properly during mouse selections (as a more portable alternative to listening to MouseUp).

Your uncancelable touch event idea 1) seems just too weird to me -- there is no analogy anywhere else in the platform, and I think it will also seem weird to web developers who will use editing-related events everywhere except for this one thing.
It should be "selectionchangeend", not "inProgress" property on "selectionchange", because of your note that at release time, it "might not actually change the selection at all".  It's too unnatural to send a selectionchange event when the selection didn't change.
Cc: yosin@chromium.org ojan@chromium.org
Components: Blink>Editing
Owner: ----
Status: Available (was: Assigned)
Summary: Add a mechanism for knowing when text selection changes have ended (was: Add a mechanism for knowing when touch text selection has ended)
Ok, let's track this as a feature request for a "selectionchangeend" event then.  yosin@, ojan@, dtapuska@, chongz@ any thoughts?

Let's keep our eyes out for other examples where developers want this in order to prioritize it properly.

Comment 10 by ojan@chromium.org, Jul 15 2016

Adding a selectionchangeend event seems totally reasonable to me. I don't see any downside aside from needing to do the work to spec and get cross vendor agreement.

Comment 11 by yosin@chromium.org, Jul 20 2016

Components: -Blink>Editing Blink>TextSelection

Comment 12 by tkent@chromium.org, Oct 12 2016

Components: -Blink>TextSelection Blink>Editing>Selection
Project Member

Comment 13 by sheriffbot@chromium.org, Oct 13 2017

Labels: Hotlist-Recharge-Cold
Status: Untriaged (was: Available)
This issue has been Available for over a year. If it's no longer important or seems unlikely to be fixed, please consider closing it out. If it is important, please re-triage the issue.

Sorry for the inconvenience if the bug really should have been left as Available. If you change it back, also remove the "Hotlist-Recharge-Cold" label.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot

Comment 14 by yosin@chromium.org, Oct 16 2017

Status: Available (was: Untriaged)

Comment 15 by ojan@chromium.org, May 8 2018

Cc: -ojan@chromium.org

Sign in to add a comment