Fake selections are where there is no native ContentEditable DOM selection, but instead a "selection" is emulated through styling, event listeners etc.
At present, we effectively have three sorts of selection:
- Null selection: soft keyboard closed, full screen view for document
- Fake selection: soft keyboard closed, full screen view for document
- Real selection: soft keyboard open, reduced viewport for document
We already fake table selections, and linear selections if the range is a focusable node. This task is to explore whether fake selections could take the place of real ones in more cases.
Reasons this would be useful
- Could fix a whole load of fiddly edge cases that arise because of the interaction between native selections, selection pins, the soft keyboard, and native selection context menus: see T209505. Significant examples include T204387 and T202723 (for iOS).
- Would be nice to get the full screen when doing edits that don't involve text input.
Reasons this is a dubious idea
- Native selections have a lot of functionality: grapheme clusters, pins, native context actions, etc. It would be infeasible to reimplement all these.
- Hard to get wrapping and bidi correct
- Native functionality is constantly improving: we would have a hard time keeping abreast
- Still need to interact with the soft keyboard sometimes
A less radical alternative would be to null the selection more aggressively, e.g. when a non-expanded cursor is scrolled away so it no longer appears in the viewport.