Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot delete embeds with backspace #4299

Closed
2 tasks
ellatrix opened this issue Jan 4, 2018 · 3 comments
Closed
2 tasks

Cannot delete embeds with backspace #4299

ellatrix opened this issue Jan 4, 2018 · 3 comments
Labels
[Feature] Writing Flow Block selection, navigation, splitting, merging, deletion...

Comments

@ellatrix
Copy link
Member

ellatrix commented Jan 4, 2018

Issue Overview

Unlike other blocks, I cannot delete any embed blocks with the backspace/delete key.

Steps to Reproduce (for bugs)

  1. Insert and select an embed block.
  2. Press backspace.
  3. Nothing happens.

Expected Behavior

Block should be deleted.

Current Behavior

Block is still there.

Possible Solution

Screenshots / Video

Related Issues and/or PRs

Todos

  • Tests
  • Documentation
@ellatrix ellatrix added the [Feature] Writing Flow Block selection, navigation, splitting, merging, deletion... label Jan 4, 2018
@aduth
Copy link
Member

aduth commented Jan 4, 2018

Related: #4011

It is probably the case that the iframe for the embed is "eating" the keyboard event, since it has the focus.

@karmatosed
Copy link
Member

As reported in #6950 this is something impacts maybe beyond embed blocks and would be good to get the ability to delete.

@aduth
Copy link
Member

aduth commented May 29, 2018

FWIW there is handling for Backspace/Delete keys in BlockListBlock to delete the current block:

case BACKSPACE:
case DELETE:
// Remove block on backspace.
const { uid, onRemove, previousBlockUid, onSelect } = this.props;
onRemove( uid );
if ( previousBlockUid ) {
onSelect( previousBlockUid, -1 );
}
event.preventDefault();
break;

It is, however, scoped to keypresses which occur directly on the focusable block wrapper, not any inputs within. This is important, of course, since a user pressing backspace to delete a bit of text in a block's input shouldn't trigger the block to delete itself. In the case of #6950, I have a counter-argument: If I insert a URL then hold backspace to delete the entered text, should the block eventually delete itself? Or would this be unexpected behavior when my intention is simply to reset the input to an empty value?

What are the blocks which fail these expectations? Can we enumerate them?

To the original issue, I think we ought to close this as a combination of "works as intended" and "won't (can't) fix".

"Works as intended" as in, when I insert an embed link and immediately press backspace, the block is deleted:

  1. Navigate to Posts > Add New
  2. Click the "Write your story" prompt
  3. Paste: https://twitter.com/i/moments/880688233641848832
  4. Press Backspace
  5. Note that the block is deleted

"Won't fix" as in, I'll make the claim that, due to same-origin policy, it is impossible to implement detection of a Backspace key event which occurs within an embed iframe, which is what I assume is meant by "select" in the original comment (i.e. clicking within the frame). Happy to be proven wrong here.

With that in mind, I suggest we close the issue, and reopen if a proof-of-concept for iframe support can be demonstrated or we want to repurpose for other specific failing blocks.

@aduth aduth closed this as completed May 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Writing Flow Block selection, navigation, splitting, merging, deletion...
Projects
None yet
Development

No branches or pull requests

4 participants