w3c / selection-api

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

No definition of hidden selections #94

Open hugoholgersson opened 6 years ago

hugoholgersson commented 6 years ago

Chrome sometimes hides selections.

For example:

<input id="field" type="text">
<script>
let i = 0;
document.addEventListener("selectionchange", function() {
  i++;
  console.log(`Selection changed: ${i}.`);
});
field.focus(); // Creates the selection.
field.blur();  // Hides the selection.
field.focus(); // Shows the hidden selection.
</script>

Hidden selections are not yet defined so I suggest we add something like:

"A hidden selection is non-empty but non-visible selection. The browser may choose to hide selections that users cannot interact with. Hiding is a way for the browser to avoid clearance (when a selection is hid) and recreation (when a selection is repainted)."

rniwa commented 6 years ago

What's the value of mentioning that in the spec? Is there any interoperability story we're hoping for?

hugoholgersson commented 6 years ago

What's the value of mentioning that in the spec?

Developers will get a better understanding of how recent versions of Chrome work.

Is there any interoperability story we're hoping for?

Yes, take above HTML:

Browser Fired selectionchange events
Edge 16 6
Firefox 57 3
Safari 11 3
Chrome 62 1

Hiding explains why Chrome only sends one selectionchange event.

hugoholgersson commented 6 years ago

Let's label this with 'Compatibility' ?