Skip to content

More accurate node selection expansion #219

@michael

Description

@michael

Given an active node selection pressing shift+down you'd expect to select the next node. However you have to press several times because the selection just follows the native behavior, e.g. set the selection focus to the next line.

In order to improve that I can't just handle shift+down and update our model selection by one offset, because this way you will loose our original selection anchor (it will just end up somewhere else).

E.g. think of this:

  • start the selection drag inside a 2-line text property
  • drag to the second line (still a text selection)
  • now press shift+down (now we have a node selection of that element)
  • now press shift+down again (another node gets selected because of our special handling)
  • now press shift+up and again shift+up (now you'd expect the original 2 line text selection) but that is destroyed now because after special-handling the shift+down a selection rerender happens which selects the entire node (as per implementation of render_selection)

However, what I can do is handle an onkeydown if shift+up/down but instead of updating the model selection, i can find a suitable new DOM selection that matches what the user expects. Basically we will leave the selection anchor untouched and just move the selection focus somewhere into the next node

Of course this needs to work accurately for reverse selections, where shift+up will move the focus up and shift+down will move the focus down by one node. There are likely some edge cases, but I think this can be managed and it will improve the user experience for heavy keyboard users.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions