question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Inline void elements cannot be deleted when selected

See original GitHub issue

Do you want to request a feature or report a bug?

This is a bug report

What’s the current behavior?

You can reproduce this easily on the Slate mentions example. Go here: https://www.slatejs.org/examples/mentions

Click one of the mentions so that it’s highlighted with the custom rounded blue border. Now press backspace or delete. You can’t delete it when it is selected. If you press right arrow and then backspace it will work fine.

image

It seems that block voids work, since examples/images works fine.

Slate: 0.57.1 Browser: Version 79.0.3945.117 (Official Build) (64-bit) OS: macOS 10.15.1 (19B88)

What’s the expected behavior?

I would expect that pressing delete would delete the mention.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:18
  • Comments:14 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
abhishekbhardwajcommented, Mar 7, 2020

@laverdet @skogsmaskin I was able to fix this last image issue by doing the following in my withImages plugin:

editor.deleteFragment = () => {
    const { selection } = editor;

    if (selection && Range.isExpanded(selection)) {
      const images = Array.from(
        Editor.nodes(editor, {
          match: n => n.type === TYPES.IMAGE
        })
      );

      if (!!images.length) {
        // We're only deleting the last image as that's what is always left behind.
        // Slate is handling the rest easily.
        const [, cellPath] = images[images.length - 1];
        Transforms.delete(editor, {
          at: cellPath,
          voids: true
        });
      }
    }

    deleteFragment();
  };

We just delete the last image in the selection and leave the rest to Slate

3reactions
vmaarkcommented, May 29, 2020

seems to be a browser specific issue, it’s working in Firefox for Mac.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Are (non-void) self-closing tags valid in HTML5?
According to the HTML5 spec, tags that cannot have any contents (known as void elements) can be self-closing*. This includes the following tags:...
Read more >
Memory Management, C++ FAQ - Standard C++
This is an opportunity to forget to delete that object. After all, we cannot tell just looking at pointer whether it needs to...
Read more >
How whitespace is handled by HTML, CSS, and in the DOM
An inline element (the <span> , which contains a space, and the word "World!"). Another text node (consisting only of tabs and spaces)....
Read more >
Deleting IAM policies - AWS Identity and Access Management
Select the check box next to the customer managed policy to delete. You can use the search box to filter the list of...
Read more >
HTML Standard
Certain invalid syntax constructs, when parsed, result in DOM trees that are highly ... For example, a button element cannot contain a textarea...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found