# Gapcursor and tables

**URL:** https://discuss.prosemirror.net/t/gapcursor-and-tables/4278
**Category:** Uncategorized
**Created:** [December 19, 2021, 10:32pm UTC](https://discuss.prosemirror.net/t/gapcursor-and-tables/4278 "2021-12-19T22:32:27Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![paulfab](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/paulfab/32/2141_2.png) [@paulfab](https://discuss.prosemirror.net/u/paulfab)
#### Post date: [December 19, 2021, 10:32pm UTC](https://discuss.prosemirror.net/t/gapcursor-and-tables/4278/1 "2021-12-19T22:32:27Z")

</div>

When using the GapCursor, I have a weird behavior

Here is the document :

![image](https://discuss.prosemirror.net/uploads/secondsite/original/2X/6/66fd24c474b8827f3484b9d0bbaa4dcdbb9f64a9.png)

A table with one row and two columns. Each cell has a horizontal line at the first position

If I hit “left” while the horizontal line in the second cell is selected, then Gapcursor works:

![image](https://discuss.prosemirror.net/uploads/secondsite/original/2X/c/c8214bf0500a46650f369b998a998f21733037e0.png)

But if I do the same in the first cell then the cursor is sent to the line before the table ( and not just before the horizontal line inside the cell)

Same things when hitting “right” on the second cell (but works while on the first cell)

Is that the expected behavior?

Thank

---

<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: [December 20, 2021, 7:05am UTC](https://discuss.prosemirror.net/t/gapcursor-and-tables/4278/2 "2021-12-20T07:05:07Z")

</div>

> [@paulfab](#):
>
> If I hit “left” while the horizontal line in the second cell is selected, then Gapcursor works:

The gap cursor is drawn as a horizontal line, so I think you’re not seeing a gap cursor in that screenshot. What do the document structure inside the cell and the DOM structure look like at this point?

---

<div class="post-metadata">

### Author: ![paulfab](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/paulfab/32/2141_2.png) [@paulfab](https://discuss.prosemirror.net/u/paulfab)
#### Post date: [December 20, 2021, 9:20am UTC](https://discuss.prosemirror.net/t/gapcursor-and-tables/4278/3 "2021-12-20T09:20:43Z")

</div>

> [@marijn](#):
>
> The gap cursor is drawn as a horizontal line,

I modified the css to make it look like a regular cursor that’s why it is not horizontal

Here is the document structure:

```auto
{
  "type": "doc",
  "content": [
    {
      "type": "paragraph",
      "attrs": {
        "align": "left"
      },
      "content": [
        {
          "type": "text",
          "text": "asfas"
        }
      ]
    },
    {
      "type": "table",
      "content": [
        {
          "type": "table_row",
          "content": [
            {
              "type": "table_cell",
              "attrs": {
                "colspan": 1,
                "rowspan": 1,
                "colwidth": [
                  50
                ],
                "background": null,
                "borderleft": "1px solid",
                "bordertop": "1px solid",
                "borderbottom": "1px solid",
                "borderright": "1px solid",
                "verticalalign": "top"
              },
              "content": [
                {
                  "type": "horizontal_rule"
                }
              ]
            },
            {
              "type": "table_cell",
              "attrs": {
                "colspan": 1,
                "rowspan": 1,
                "colwidth": [
                  49.89293361884368
                ],
                "background": null,
                "borderleft": "1px solid",
                "bordertop": "1px solid",
                "borderbottom": "1px solid",
                "borderright": "1px solid",
                "verticalalign": "top"
              },
              "content": [
                {
                  "type": "horizontal_rule"
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}

```

And here is the dom:

```auto
<div class="tableWrapper">
   <table>
      <colgroup>
         <col style="width: 50%;">
         <col style="width: 49.8929%;">
      </colgroup>
      <tbody>
         <tr>
            <td class="cell-prosemirror" data-colwidth="50" style="border-left: 1px solid;border-top: 1px solid;border-bottom: 1px solid;border-right: 1px solid;vertical-align: top;">
               <hr class="" contenteditable="false">
            </td>
            <td class="cell-prosemirror" data-colwidth="49.89293361884368" style="border-left: 1px solid;border-top: 1px solid;border-bottom: 1px solid;border-right: 1px solid;vertical-align: top;">
               <div class="ProseMirror-gapcursor ProseMirror-widget" contenteditable="false"></div>
               <hr class="" contenteditable="false">
            </td>
         </tr>
      </tbody>
   </table>
</div>

```

From inspecting the code, the difference when you hit “left” on the second cell or a the first cell is the returns of [closedBefore](https://github.com/ProseMirror/prosemirror-gapcursor/blob/0b0283f638273d9e928de10d175c91a29c64daac/src/gapcursor.js#L101) which returns `false` in the first cell and `true` in the second cell

---

<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: [December 20, 2021, 9:51am UTC](https://discuss.prosemirror.net/t/gapcursor-and-tables/4278/4 "2021-12-20T09:51:28Z")

</div>

Does [this patch](https://github.com/ProseMirror/prosemirror-gapcursor/commit/e1aa6741ce6d94981e4ca64f05508ff4d4d5db4e) help with this issue?

---

<div class="post-metadata">

### Author: ![paulfab](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/paulfab/32/2141_2.png) [@paulfab](https://discuss.prosemirror.net/u/paulfab)
#### Post date: [December 20, 2021, 10:07am UTC](https://discuss.prosemirror.net/t/gapcursor-and-tables/4278/5 "2021-12-20T10:07:21Z")

</div>

Yes totally solved it, thank you very much

---

<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: [December 20, 2021, 10:27am UTC](https://discuss.prosemirror.net/t/gapcursor-and-tables/4278/6 "2021-12-20T10:27:06Z")

</div>

Great, tagged as prosemirror-gapcursor 1.2.1.
