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

Unexpected backspace/delete key handling in nested lists #1259

Closed
Kirkkt opened this issue Apr 4, 2022 · 3 comments
Closed

Unexpected backspace/delete key handling in nested lists #1259

Kirkkt opened this issue Apr 4, 2022 · 3 comments

Comments

@Kirkkt
Copy link

Kirkkt commented Apr 4, 2022

Hi team ProseMirror,

We are Pitch are building our next-gen text editor using ProseMirror and it has been great. So first of all big kudos!!

However, we encountered some unexpected behaviors when pressing backspace/delete in nested lists.

Steps to repro:

  1. go to https://prosemirror.net/
  2. create some nested lists, like this one:

image

  1. (see below)

Issue 1: press delete or backspace on range selection, all bullet points stay

image

Expected: these 2 lines get removed, together with the bullet points

Actual: all bullet points stay

image

Issue 2: press delete or backspace on range selection, some bullet points stay

This is (I think) basically the same thing as issue 1, but more confusing for everyday users

image

Expected: these 3 lines get removed, together with the bullet points

Actual: 1 bullet point stays

image

Issue 3: put cursor at the end of a line and press delete, if the "join next line" op will break the scheme, the delete doesn't happen, and a chunk of list is selected below

image

Expected: well this is a bit hard to say, an everyday user might expect the list structure to be re-adjusted to allow this deletion, and I (who has played with ProseMirror for a few weeks) might expect at least nothing happens because it can be categorized as an "illegal" operation.

Actual: no deletion happens, and 4 lines below are selected

image

Issue 4: put cursor at the start of a line and press backspace, if the "join to prev line" op will break the scheme, the delete doesn't happen, and a chunk of list is selected below

image

Expected: similar to issue 3

Actual: no deletion happens, and the line above is selected

image

I'm very satisfied and impressed by the richness and simplicity of ProseMirror, but list handling seems to have missed some love. Would you kindly take a look? Thank you very much.

@marijnh
Copy link
Member

marijnh commented Apr 4, 2022

Because there are nested list items outside of the deleted range, which cannot exist without parent nodes, those list items must be preserved in order to satisfy the document shape prescribed by the schema. You could try add custom deletion logic that behaves differently, and bind it to the delete and backspace keys, but as for core library logic, this is expected behavior.

@Kirkkt
Copy link
Author

Kirkkt commented Apr 4, 2022

Hi @marijnh thanks for the explanation.

I will add a custom delete/backspace command as you suggested, but there is still something I don't quite get:

image

After you press backspace/delete you get:

image

In this case, the second bullet point should be removed, right? It also conforms to the "no children without parent" rule and should satisfy the schema.

But here's something interesting: if you only partially select the second item, it works nicely:

image

After you press backspace/delete you get:

image

Is this a bug?

marijnh added a commit to ProseMirror/prosemirror-transform that referenced this issue Apr 5, 2022
…aceStep

FIX: Make replacements that span to the end of a textblock more consistent with
those ending in the middle of the block.

Issue ProseMirror/prosemirror#1259
@marijnh
Copy link
Member

marijnh commented Apr 5, 2022

That does seem surprising. Attached patch makes the two cases behave more consistently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants