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.

Focusing on ComponentDidMount.

See original GitHub issue

When i do this:

componentDidMount() {
  this.refs.editor.focus();
}

To put the cursor inside the box, the plugins no longer work. Any ideas?

Issue Analytics

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

github_iconTop GitHub Comments

13reactions
stefan1968commented, Jul 15, 2016

I fixed this by doing a setTimeout call to focus with a zero delay.

On 15 Jul 2016 7:45 p.m., “prabodh” notifications@github.com wrote:

It happens in my setup too…to be precise, when i call focus in componentDidMount , mention plugin does not work…there are no errors in the console…i dont have a public reproduce setup for this bug…but will try to get one and post if it helps

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/draft-js-plugins/draft-js-plugins/issues/357#issuecomment-233035081, or mute the thread https://github.com/notifications/unsubscribe-auth/AFPshuap098jrIywnVDaofQJSthBPPZPks5qV9U4gaJpZM4JMizZ .

3reactions
misteriosscommented, Nov 27, 2017

Yes, it does.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React: set focus on componentDidMount, how to do it with ...
In React, with classes I can set the focus to an input when the component loads, something like this: class Foo extends React....
Read more >
How to Set Focus On Element After Rendering With React
In this guide, learn how to set focus on an element after JavaScript's React component renders it, using functional and class components.
Read more >
Call a function when focused screen changes | React Navigation
In this guide we will call an action on screen focusing. This is useful for making additional API calls when a user revisits...
Read more >
How to focus element in React | Tuomo Kankaanpää
To get the input autofocus when the component is rendered, we call focus() on the textInput variable in the componentDidMount() method.
Read more >
How To Set Focus On Input After Render In React 16
Simple example of how to set focus on input after render in React 16. ... Inside of our componentDidMount method we're calling focus()...
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