Closed Reinmar closed 3 years ago
There are two separate problems that contribute to the glitches with mouse selection anchoring at links/markers/mentions:
We never want to have the DOM selection start before the inline filler (not sure why, though). But this sometimes happens randomly as the user starts selection at a different point (geometrically, using the mouse).
And we fix this if it happens. And as we fix it, we break the flow of the user selection https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/view/domconverter.js#L1013-L1016
// What user did by accident
// (also, imagine they are moving mouse right to select more)
<p>[]&NBR;&NBR;&NBR;&NBR;&NBR;&NBR;&NBR;<a>FOO</a></p>
// We fix into by imperatively collapsing it in DOM.
<p>&NBR;&NBR;&NBR;&NBR;&NBR;&NBR;&NBR;[]<a>FOO</a></p>
// Which breaks the flow of creating the selection using mouse;
// the selection remains collapsed forever despite moving mouse right.
// BTW: The filler will be also removed (see the second problem) in this case so
// this HTML is just to give you the idea of what happened.
<p>&NBR;&NBR;&NBR;&NBR;&NBR;&NBR;&NBR;<a>FO[]O</a></p>
This could be fixed by blocking the imperative rendering of the DOM selection while the selection is being made (which is the scope of the research).
While the selection is being made, the inline filler disappears because it's no longer needed. When it disappears, the DOM selection anchored in that filler is collapsed by the web browser to the focus position. Then, as the user continues moving the cursor using the mouse, it stays collapsed forever.
// That's cool. We need this filler.
<p>&NBR;&NBR;&NBR;&NBR;&NBR;&NBR;&NBR;[]<a>FOO</a></p>
// But now the inline filler is obsolete...
<p>&NBR;&NBR;&NBR;&NBR;&NBR;&NBR;&NBR;[<a>F]OO</a></p>
// So the filler is out and the browser DOM selection collapses to the focus position.
// The flow of extending the selection using the mouse was broken.
<p><a>F[]OO</a></p>
This could be fixed by keeping the inline filler as long as the selection stays in the same block.
_needsInlineFillerAtSelection()
and _isSelectionInInlineFiller()
Provide a description of the task
Research needed to move forward #10230.
Scope: Researching this point:
Source: https://github.com/ckeditor/ckeditor5/issues/10230#issuecomment-904686994