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.

Attempting to focus an Editor component on componentDidMount causes all plugins to fail

See original GitHub issue

If the parent component of the Editor tries to focus on the Editor during componentDidMount, no plugins will work.

The issue is reproduced in this repository: https://github.com/rohannair/test-draft-js/ where the master branch is properly working but the cdm_focus_bug branch is not. This is the diff of the change: https://github.com/rohannair/test-draft-js/pull/1

Thanks to @adrianmcli for helping me figure this out: 🍾

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

6reactions
paulyoungcommented, Jan 11, 2017

I’m doing this:

componentDidMount() {
  window.requestAnimationFrame(() => {
    this.refs.editor.focus();
  });
}
0reactions
stale[bot]commented, Sep 10, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Managing Focus | Draft.js
Managing text input focus can be a tricky task within React components. The browser.
Read more >
React.js - input losing focus when rerendering - Stack Overflow
The loss of focus happens because the component prop uses React.createElement each time instead of just re-rendering the changes. Details here: https:// ...
Read more >
react-quill - npm
ReactQuill will initialize the editor using defaultValue , but won't try to reset it after that. The onChange callback will still work as ......
Read more >
Visual COBOL - Micro Focus
resellers or distributors will be held liable for any damages caused or ... If we have a number of COBOL components in an...
Read more >
How To Convert React Class Components to Functional ...
With Hooks, you can create functional components that use state and lifecycle ... Let's consider a class with state and componentDidMount .
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