Page MenuHomePhabricator

VE article editor should never have a NullSelection
Closed, ResolvedPublic

Description

Many document editors (GoogleDocs, LO Writer) do not allow you to fully de-select the document. VE does but this can be quite confusing to users as it results in most tools becoming disabled (as they require a cursor position to be usable).

A brief history of NullSelections:

  • In the distant past, the document always had a model range, and blurring the document would not change this, so click an insert tool would just insert content at the last known offset. This was slightly unexpected as there was no cursor on the page to tell you where the content was going to be inserted.
  • Because of this and other issues with the model/view selections being out of sync we introduced a NullSelection to represent the state of there being no native selection on the document.
  • Separately we had an iFrame solution for allowing multiple selections on the page (for inspectors). Once this became un-maintainable we came up with fake "de-activated" selections that drew boxes using the getClientRects API

Using fake "de-activated" selections there is now no reason we can't force the document to never have a null-selection, and just show these fake selections whenever the real native selection is removed from the document.

For some use cases, such as Structured Discussion, where the VE surface behaves more like a textarea, it will probably make sense to keep the NullSelection behaviour.

Event Timeline

Change 500741 had a related patch set uploaded (by Esanders; owner: Esanders):
[VisualEditor/VisualEditor@master] Make null-selection-on-blur optional

https://gerrit.wikimedia.org/r/500741

Change 500741 merged by jenkins-bot:
[VisualEditor/VisualEditor@master] Make null-selection-on-blur optional

https://gerrit.wikimedia.org/r/500741

Change 501385 had a related patch set uploaded (by Bartosz Dziewoński; owner: Bartosz Dziewoński):
[mediawiki/extensions/VisualEditor@master] Update VE core submodule to master (2dc41ef9b)

https://gerrit.wikimedia.org/r/501385

Change 501385 merged by jenkins-bot:
[mediawiki/extensions/VisualEditor@master] Update VE core submodule to master (2dc41ef9b)

https://gerrit.wikimedia.org/r/501385

As the core patches have been merged, you can test this on beta labs by pasting ve.init.target.surface.nullSelectionOnBlur = false; into the console after VE has loaded (e.g. https://en.wikipedia.beta.wmflabs.org/wiki/Abraham_Lincoln?veaction=edit)