# Backspace after list

**URL:** <https://discuss.prosemirror.net/t/backspace-after-list/4229>\
**Category:** Uncategorized\
**Created:** [November 25, 2021, 9:15am UTC](https://discuss.prosemirror.net/t/backspace-after-list/4229 "2021-11-25T09:15:30Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![tslocke](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/tslocke/32/2218_2.png) [@tslocke](https://discuss.prosemirror.net/u/tslocke)\
**Post date:** [November 25, 2021, 9:15am UTC](https://discuss.prosemirror.net/t/backspace-after-list/4229/1 "2021-11-25T09:15:30Z")

</div>

I’ve been reading with interest the post from back in 2015 where the basics ideas of finding a happy balance between familiar WYSIWYG expectations, and principled, schema-agnostic structured editing, were hashed out. The result is a really great achievement. There is a lot more to ProseMirror than meets the eye:

> [@Backspace and Enter (and Delete, I guess)](https://discuss.prosemirror.net/t/backspace-and-enter-and-delete-i-guess/57):
>
> So the initial ad-hoc behavior I programmed turned out to be [woefully inadequate](https://github.com/ProseMirror/prosemirror/issues/21) (to my defense, it wasn’t much worse than that in many widely used WYSIWYG tools). But I wanted to define these in a way that actually followed some principle more rigorous than ‘I guess this is sort of what other tools do’. So I searched for literature on the subject. This was actually really hard to find—either I didn’t find the right jargon, or academics are so embarrassed by WYSIWYG-style editing interfaces tha…

There is one place where the current behaviour, while perhaps logical, feels counterintuitive to me (`|` is the caret):

```
  * Hello
  |World

```

Hit backspace. I’d expect:

```
* Hello|World

```

But I get:

```
* Hello
* |World

```

Later in that thread, @marijn mentions “I’ve come to realize that having ‘auto splitting list items’ actually doesn’t interfere with the behavior I defined in any problematic way.” - [Backspace and Enter (and Delete, I guess) - #11 by marijn](https://discuss.prosemirror.net/t/backspace-and-enter-and-delete-i-guess/57/11)

If I’m following correctly, this insight allowed the more familiar single enter to create a new list item, rather than two presses of enter. I’m wondering if there could also be “auto joining list items” to get the more familiar behaviour indicated above. There is a nice symmetry in that, with auto-splitting list items, a single backspace gets you the non-auto-splitting behaviour, while with auto-joining, a single enter would do the same.

Has such a thing been considered?

Any advice on attempting an implementation?

(I have a related question, where backspacing a blank paragraph between two of my custom block types is problematic, because they join together. Imagine a block type rendered with a border, such that, unlike bullet lists, it makes sense to have two adjacent to each other while retaining there separateness. I’ll save that for another post but I think the issue is closely related so I thought I’d mention it)

Thanks!

---

<div class="post-metadata">

**Author:** ![marijn](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/marijn/32/15_2.png) [@marijn](https://discuss.prosemirror.net/u/marijn)\
**Post date:** [November 25, 2021, 10:30am UTC](https://discuss.prosemirror.net/t/backspace-after-list/4229/2 "2021-11-25T10:30:28Z")

</div>

Implementing custom key behavior is generally done by defining a [command function](https://prosemirror.net/docs/ref/#commands) that first checks whether the situation you want to override applies, and if so performs the desired action and returns true, and binding that to the appropriate key with a higher precedence than the other handlers.

Automatically joining surrounding blocks when a paragraph between them is deleted is done because for things like lists and blockquotes people tend to expect it. It might make sense to have a node spec property that disables it—I’d be open to a pull request that adds that.

---

<div class="post-metadata">

**Author:** ![tslocke](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/tslocke/32/2218_2.png) [@tslocke](https://discuss.prosemirror.net/u/tslocke)\
**Post date:** [November 25, 2021, 10:47am UTC](https://discuss.prosemirror.net/t/backspace-after-list/4229/3 "2021-11-25T10:47:37Z")

</div>

Do I take it that you don’t think auto-joining list items is a good idea? For the default behaviour I mean.

I’ll have a look into the PR you suggest.

---

<div class="post-metadata">

**Author:** ![marijn](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/marijn/32/15_2.png) [@marijn](https://discuss.prosemirror.net/u/marijn)\
**Post date:** [November 25, 2021, 11:55am UTC](https://discuss.prosemirror.net/t/backspace-after-list/4229/4 "2021-11-25T11:55:54Z")

</div>

I don’t entirely remember what reasoning the default joining behavior is based on, but that should definitely not change except when explicitly opted out of.

---

<div class="post-metadata">

**Author:** ![tslocke](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/tslocke/32/2218_2.png) [@tslocke](https://discuss.prosemirror.net/u/tslocke)\
**Post date:** [November 25, 2021, 12:22pm UTC](https://discuss.prosemirror.net/t/backspace-after-list/4229/5 "2021-11-25T12:22:32Z")

</div>

From the contributing guide:

> If you want to make a change that … introduces a user-visible new feature, create an RFC first with your proposal.

Given you’ve proposed the PR in the first place, I wasn’t sure if I should do that or not.

This looks to be a pretty small change BTW unless I’m missing something (entirely likely!). Here’s my starting point:

> <https://github.com/tslocke/prosemirror-commands/commit/1b21a1c35913e5f506be41c9d889d1775494eb23>

---

<div class="post-metadata">

**Author:** ![marijn](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/marijn/32/15_2.png) [@marijn](https://discuss.prosemirror.net/u/marijn)\
**Post date:** [November 25, 2021, 12:53pm UTC](https://discuss.prosemirror.net/t/backspace-after-list/4229/6 "2021-11-25T12:53:39Z")

</div>

No, this would be small enough to not bother with an RFC. What kind of nodes do you need this for, by the way? Would `isolating` maybe be applicable to them?

---

<div class="post-metadata">

**Author:** ![tslocke](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/tslocke/32/2218_2.png) [@tslocke](https://discuss.prosemirror.net/u/tslocke)\
**Post date:** [November 25, 2021, 1:39pm UTC](https://discuss.prosemirror.net/t/backspace-after-list/4229/7 "2021-11-25T13:39:50Z")

</div>

> [@marijn](#):
>
> Would `isolating` maybe be applicable to them?

I don’t think so. I tried that first. I still want the double-enter behaviour to break out of the block, and I want to be able to backspace at the very start of the block, in some circumstances.

---

<div class="post-metadata">

**Author:** ![marijn](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/marijn/32/15_2.png) [@marijn](https://discuss.prosemirror.net/u/marijn)\
**Post date:** [November 25, 2021, 2:12pm UTC](https://discuss.prosemirror.net/t/backspace-after-list/4229/8 "2021-11-25T14:12:26Z")

</div>

Makes sense.

I don’t think just completely turning off the `deleteBarrier` behavior is the way to go here, though—just the part that joins otherwise unaffected nodes after you delete an empty block.

---

<div class="post-metadata">

**Author:** ![tslocke](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/tslocke/32/2218_2.png) [@tslocke](https://discuss.prosemirror.net/u/tslocke)\
**Post date:** [November 25, 2021, 5:07pm UTC](https://discuss.prosemirror.net/t/backspace-after-list/4229/9 "2021-11-25T17:07:12Z")

</div>

Made the mistake of mixing two topics in one thread, so I’d just like to retrieve the original question. If I have…

```auto
  * Hello
  |World

```

…and I hit backspace. I’d expect

```auto
* Hello|World

```

but I get:

```auto
* Hello
* |World

```

Is this what you were referring to that “should definitely not change”. If so, can I respectfully ask why? It is very unusual behaviour.

---

<div class="post-metadata">

**Author:** ![marijn](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/marijn/32/15_2.png) [@marijn](https://discuss.prosemirror.net/u/marijn)\
**Post date:** [November 25, 2021, 8:47pm UTC](https://discuss.prosemirror.net/t/backspace-after-list/4229/10 "2021-11-25T20:47:17Z")

</div>

It’s often useful to be able to move blocks into adjacent parent blocks. The way `joinBackward` is defined is that it’ll move the content after the cursor across one node boundary before the cursor, which, if a nested block node starts there, means moving into that.
