question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unwanted selection's restoring when re-focusing

See original GitHub issue

Steps: - Select some characters - Click outside the editor ( or blur ) - Click inside the editor ( or focus )

Instead of creating a new collapsed selection where I clicked, it restores the same selection that I made before blurring. It doesn’t happen when I blur and the selection is collapsed

I was able to solve it “removing” the selection on blur since it doesn’t happen when the selection is collapsed, but I think this is a bug and we I should report it.

It happens on both chrome and firefox, I haven’t tested on others.

  constructor(props) {
    super(props);
    ...
    this.blur = () => this.refs.editor.blur()
    ...
  }

  onBlur(e) {
    setTimeout(this.moveFocusIfNotCollapsed, 0)
  }

  moveFocusIfNotCollapsed() {
    if (!this.state.editorState.getSelection().isCollapsed()) {
      this.setState({
        editorState: EditorState.moveFocusToEnd(this.state.editorState)
      }, this.blur)
    }
  }

  render() {
    const { editorState } = this.state;
    return (
      <div className="note-editor">
        <Editor
          ref="editor"
          blockStyleFn={this.getBlockStyle}
          editorState={editorState}
          onBlur={this.onBlur}
          onChange={this.onChange}
        />
    )
  }

Draft 0.8.1

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
elfeycommented, Mar 27, 2017

So how do we fix this?

1reaction
dreday966commented, Apr 26, 2017

So how do we fix this? +1. I spent one hour in this bug, thought this is because moveSelectionToEnd doesn’t work, but I found out that it’s due to chrome. moveSelectionToEnd works in Safari

Read more comments on GitHub >

github_iconTop Results From Across the Web

Best 5 Photo Apps to Remove Unwanted Objects on Your ...
Some software experts have designed creative apps to remove unwanted objects from photos. In this article, we are going to discuss some of ......
Read more >
Detect and get rid of unwanted sneaky mobile redirects
Check your site on a mobile device or through emulation between each script/element removal, and see when the redirect stops.
Read more >
10 Ways To Refocus Your Career During a Midlife Crisis
You may think that the problem is your salary, your position or a routine that you may now find undesirable. The following questions...
Read more >
Adiabatic refocusing pulses for volume selection in ...
Percentage of signal recovery for (a ) two orthogonal AFP pulses and (b ) ... Unwanted coherences caused by imperfect refocusing were removed ......
Read more >
Photoshop releases major update to Selections, Hole ...
Remove unwanted elements in your image faster than you can say one-click ... The Photo Restoration Neural Filter helps you bring an old...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found