Page MenuHomePhabricator

VE fails to place cursor when document starts with a table
Open, Needs TriagePublic

Description

  1. Open a document that starts with a table, followed by a paragraph

Observed

  1. No cursor is placed in the document

Expected

  1. The cursor is placed in the paragraph beneath the table [i]

i. We already have equivalent behaviour with block images, where we don't try and place the cursor in the image caption, even though it is technically the first (wrapper) paragraph on the page

Event Timeline

The flag being used here is ve.dm.Node.static.ignoreChildren which is true on block image nodes, but false on tables. This flag is vaguely documented as:

* Whether this node's children should be ignored. If true, this node will be treated as a leaf
* node even if it has children. Often used in combination with handlesOwnChildren.

I think in this situation we are trying to determine something in the model which should actually rely on properties of the view nodes, specifically we should skip over view nodes which mixin ve.ce.ActiveNode (and which aren't currently active).

The following currently use ignoreChildren:

  • Block images
  • Reference lists (which can contain mwReference nodes, e.g. <references><ref>foo</ref></references>
  • Internal items (where we store reference contents)

It seems like block images is the odd one out here, and anywhere we are relying on this behaviour in the view, we should be using ve.ce.ActiveNode state instead.

Change 739598 had a related patch set uploaded (by Bartosz Dziewoński; author: Esanders):

[VisualEditor/VisualEditor@master] Move logic for select first/last offset to view and consider active nodes

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

It seems like block images is the odd one out here, and anywhere we are relying on this behaviour in the view, we should be using ve.ce.ActiveNode state instead.

On reflection, ActiveNode is not the right thing to consider here, as some active nodes should be auto-focusable (e.g. SectionNode). We should just introduce a new view node property (e.g. autoFocus) which is true by default, but disabled on tables and block images.

Change 742728 had a related patch set uploaded (by Esanders; author: Esanders):

[mediawiki/extensions/VisualEditor@master] Pull through Idc0cccbe73

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