w3c / selection-api

Selection API
http://w3c.github.io/selection-api/
Other
47 stars 30 forks source link

Define behavior for user action of "selecting all". #105

Open mbrodesser opened 5 years ago

mbrodesser commented 5 years ago

It's currently unspecified, how user agents should use the selection API when selecting all elements on a page, for instance via pressing CTRL+a.

This is required to align and preserve the behavior across browsers.

johan commented 5 years ago

The Select All action also lacks an event to subscribe to, necessitating web developers to bind arbitrary localized keyboard shortcuts like ctrl/cmd-a if they want to do a sane contextual action in response to it — which still won’t happen if you pick Edit → Select All from the window or context menu.

rniwa commented 5 years ago

Knowing the contextual information about selection change is https://github.com/w3c/selection-api/issues/56.

I'm not certain what you mean by specifying the behavior when selecting all text in a page. What the browser may do in response to mouse / keyboard input is in fact implementation dependent because platform conventions would differ.

mbrodesser commented 5 years ago

Having reconsidered the issue, I agree. It seems reasonable to assume that browsers call selectAllChildren when a user triggers the "Select All" mechanism (one way or the other). Closing this issue.

mbrodesser commented 5 years ago

Outside of this ticket, @annevk brought up the following idea:

the underlying concept of "Select All" could be described in a separate section. selectAllChildren of the API would invoke it. Moreover, a "User actions" section would describe various means (on-screen keyboard, hardware keyboard, context-menu, perhaps others) in a platform-independent manner, which invoke that concept too. The separation of concept and API would have the additional advantage that other specifications could refer to the concept, instead of the API, which can be overridden.

rniwa commented 5 years ago

Sure, I think defining what selectAllChildren does make sense.

johan commented 5 years ago

the underlying concept of "Select All" could be described in a separate section.

Defining the Selection api's selectAllChildren() semantics seems useful,

selectAllChildren of the API would invoke it. Moreover, a "User actions" section would describe various means (on-screen keyboard, hardware keyboard, context-menu, perhaps others) in a platform-independent manner, which invoke that concept too.

...but not tightly mapped to what a user invoking their browser's "Select All" action should do (except perhaps as a default action in a normal DOM page editing context).

If the visited web app is some kind of productivity app or game, that seems to fall under #56. DOM tree operations like selectAllChildren would not be the wanted immediate effect, rather something the app can capture to translate it to arbitrary actions like "select all emails", "select all the tavern's inventory", or whatever its current context is about.