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

Removing the last block breaks selection #2297

Closed
ericedem opened this issue Oct 22, 2018 · 2 comments
Closed

Removing the last block breaks selection #2297

ericedem opened this issue Oct 22, 2018 · 2 comments

Comments

@ericedem
Copy link
Contributor

Do you want to request a feature or report a bug?

bug

What's the current behavior?

Removing the last block, or starting with no blocks, leaves the selection in a broken state once blocks are added. I was able to reproduce this with several test cases, this one tests insterting a block into an empty document:

/** @jsx h */

import h from '../../../helpers/h'

export default function(change) {
  change.replaceNodeByKey('a', { object: 'block', type: 'quote' })
}

export const input = (
  <value>
    <document>
      <paragraph key="a">one</paragraph>
    </document>
  </value>
)

export const output = (
  <value>
    <document>
      <quote />
    </document>
  </value>
)

With the resulting output:
https://gist.github.com/ericedem/21bd5aa094268b89b5e7d79bfc1b7ab8

I think this is causing or at least related to a few issues opened since 0.42 namely: #2289, #2279

What's the expected behavior?

I think what should happen is that the selection should be restored to the beginning of the first block when one is inserted. Though this still leaves the editor in a strange state if someone removes a node and tries to do something in the middle.

Anyone got any ideas on how this should behave?

@ianstormtaylor
Copy link
Owner

I'm not really sure about a good solution here. It might be things to fix at the source in the specific places it's causing issues, not assuming that a selection is "set".

One "solution" would be to use unset selections more often, whenever something is blurred, so that people don't assume the selection will always be set?

@ianstormtaylor
Copy link
Owner

Fixed by #3093.

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

Successfully merging a pull request may close this issue.

2 participants