Slate: Bug: insert value to an empty table cell does not work

Created on 29 Jan 2018  Â·  10Comments  Â·  Source: ianstormtaylor/slate

What's the current behavior?

In the table demo link, it is impossible to write a value to a table cell if the cell is empty

pw62t2kgsq

bug ♥ help

Most helpful comment

Let us fix it after https://github.com/ianstormtaylor/slate/issues/1561

I think perhaps there is a bug of carrying mark in selection normalization.

All 10 comments

Thanks for the report, I can reproduce this as well (macOS/Chrome 64)

The bug is caused by

  onKeyDown = (event, change) => {
    const { value } = change
    const { document, selection } = value
    const { startKey } = selection
    const startNode = document.getDescendant(startKey)

    if (selection.isAtStartOf(startNode)) {
      const previous = document.getPreviousText(startNode.key)
      const prevBlock = document.getClosestBlock(previous.key)

      if (prevBlock.type == 'table-cell') {
        event.preventDefault()
        return true
      }
    }

Where

      if (prevBlock.type == 'table-cell') {
        event.preventDefault()
        return true
      }

disable the text insert;

I think we shall only disable delete operations; or at least pass the insert operations

Yeah I agree, that seems to be correct. Looks like it's only a problem with the example implementation and not with slate itself. @zhujinxuan want to send a PR fixing that?

@schneidmaster Yes, give me some minutes~

A bug happens when insert at start:
Strangely, the text is bolded

Hmm, looks like it's carrying over the bold mark from the previous cell? (Maybe due to #1561)

Let us fix it after https://github.com/ianstormtaylor/slate/issues/1561

I think perhaps there is a bug of carrying mark in selection normalization.

Any updates regarding this bug?

@amitm02 Oh, I forgot that. I will submit a PR in this week.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vdms picture vdms  Â·  3Comments

Slapbox picture Slapbox  Â·  3Comments

JSH3R0 picture JSH3R0  Â·  3Comments

yalu picture yalu  Â·  3Comments

ianstormtaylor picture ianstormtaylor  Â·  3Comments