gutenberg icon indicating copy to clipboard operation
gutenberg copied to clipboard

Pressing Delete with a multi-block selection spanning from a paragraph doesn't delete

Open ephox-mogran opened this issue 9 years ago • 4 comments

Issue Overview

When a multi-selection spans from a paragraph block, pressing <del> or <backspace> does not delete the selected blocks.

Steps to Reproduce (for bugs)

  1. Create multiple paragraph blocks.
  2. Select from the text of one paragraph down to the last paragraph
  3. Press Delete

Browser: Chrome

Expected Behavior

All the selected blocks will be deleted.

Current Behavior

There are two behaviours:

a) if you selected some text in the first block, then that text is just deleted b) if you hadn't selected any text in the first block (so you started dragging from past the last word), then it triggers a merge operation with the next block so it looks like some deletion has occurred, but not the deletion that you wanted.

Possible Solution

It's caused by the fact that Delete / Backspace is being handled by the editor (either deleting text or firing merge). I'm going to try and make the editor in read-only mode whenever a multi-selection has occurred and see what that looks like. That may or may not be a solution.

Related Issues and/or PRs

Todos

  • [x] Tests
  • [x] Documentation

ephox-mogran avatar Oct 26 '17 22:10 ephox-mogran

Another approach will be to focus the outer container and remove selection from the window.

ephox-mogran avatar Oct 26 '17 23:10 ephox-mogran

So stopping focus going through to the block itself (passing null) when there is a multi-selection works fairly well, but after deleting the blocks, there is no block focused. Investigating how to resolve that.

ephox-mogran avatar Oct 27 '17 00:10 ephox-mogran

This also affects blocks like Heading, but the fix attached covers all cases. 👌

mcsf avatar Oct 27 '17 10:10 mcsf

This was last fixed in #2934 I believe, after it had been broken for a while. Would be great to know what broke it again.

ellatrix avatar Oct 27 '17 15:10 ellatrix