# Inconsistent behavior with Selection and "atom" Node

**URL:** <https://discuss.prosemirror.net/t/inconsistent-behavior-with-selection-and-atom-node/2556>\
**Category:** Uncategorized\
**Created:** [February 24, 2020, 10:51pm UTC](https://discuss.prosemirror.net/t/inconsistent-behavior-with-selection-and-atom-node/2556 "2020-02-24T22:51:24Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![raphaelsantos](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/raphaelsantos/32/1349_2.png) [@raphaelsantos](https://discuss.prosemirror.net/u/raphaelsantos)\
**Post date:** [February 24, 2020, 10:51pm UTC](https://discuss.prosemirror.net/t/inconsistent-behavior-with-selection-and-atom-node/2556/1 "2020-02-24T22:51:24Z")

</div>

My app has a line with text where I can add text inputs (they are wrapped in webcomponents and set as “atom” Nodes, unselectable and “isolating”.

They work as expected except if there is no content right after the node, in this case the text inputs get removed upon pressing backspace while writing inside it. If there is some text right after the node it does not happen.

I was investigating a bit and notice that that if “editorView.state.selection.from” matches the index right after my text input node it gets removed upon pressing backspace, if it is another value (because I entered text after adding the node, or clicked somewhere else before focusing on the text input field) it doesn’t get removed and the backspace seems to be completely ignored (I would expect it to remove whatever is at selection index).

Are there any settings that I am supposed to use in this case? Or should I write some code to handle transactions differently whenever the text input webcomponent has focus?

---

<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:** [February 25, 2020, 8:23am UTC](https://discuss.prosemirror.net/t/inconsistent-behavior-with-selection-and-atom-node/2556/2 "2020-02-25T08:23:22Z")

</div>

You mention editing inside the nodes. Is that done in another control (which is separately focused), or is that still ProseMirror managing the editing, via a `contentDOM` on the node view?

---

<div class="post-metadata">

**Author:** ![raphaelsantos](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/raphaelsantos/32/1349_2.png) [@raphaelsantos](https://discuss.prosemirror.net/u/raphaelsantos)\
**Post date:** [February 25, 2020, 2:32pm UTC](https://discuss.prosemirror.net/t/inconsistent-behavior-with-selection-and-atom-node/2556/3 "2020-02-25T14:32:12Z")

</div>

Hi @marijn, I set these properties to my component’s nodeSpec

```auto
    atom: true,
    isolating: true,
    inline: true,
    selectable: false,

```

I was expecting ProseMirror to ignore any inputs while the focus is on my component, and it seems to be the case. Apparently the only exception is if the selection points to the index right after the component and I press backspace, which removes the node holding my component. I’m not using ProseMirror inside my component, it’s an implementation of Google Material text input.

I’m not using `contentDom`.

---

<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:** [February 25, 2020, 2:57pm UTC](https://discuss.prosemirror.net/t/inconsistent-behavior-with-selection-and-atom-node/2556/4 "2020-02-25T14:57:52Z")

</div>

If focus is on your node view, you can use the `stopEvent` method on your node view object to prevent ProseMirror from handling events inside it.

---

<div class="post-metadata">

**Author:** ![raphaelsantos](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/raphaelsantos/32/1349_2.png) [@raphaelsantos](https://discuss.prosemirror.net/u/raphaelsantos)\
**Post date:** [February 25, 2020, 3:05pm UTC](https://discuss.prosemirror.net/t/inconsistent-behavior-with-selection-and-atom-node/2556/5 "2020-02-25T15:05:39Z")

</div>

The removal is happening at this line.

> <https://github.com/ProseMirror/prosemirror-view/blob/master/src/capturekeys.js#L198>

---

<div class="post-metadata">

**Author:** ![raphaelsantos](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/raphaelsantos/32/1349_2.png) [@raphaelsantos](https://discuss.prosemirror.net/u/raphaelsantos)\
**Post date:** [February 25, 2020, 7:24pm UTC](https://discuss.prosemirror.net/t/inconsistent-behavior-with-selection-and-atom-node/2556/6 "2020-02-25T19:24:57Z")

</div>

Hi @marijn, your `stopEvent()` suggestion worked for me.

Thanks for your time!
