signavio / react-mentions

@mention people in a textarea
https://react-mentions.vercel.app
Other
2.4k stars 560 forks source link

Cannot focus programmatically, because inputRef becomes null after typing something into the MentionInput #747

Open torlenor opened 2 months ago

torlenor commented 2 months ago

Steps to reproduce:

  1. Open the demo locally or via https://react-mentions.vercel.app/
  2. Go to Advanced options
  3. Click somewhere so that the MentionsInput is not focused
  4. Click on the button "focus programmatically"
  5. It works
  6. Now type something in the text field, click outside so that it is unfocused
  7. Click on the button "focus programmatically"
  8. It fails until you reload the page.

Expected behaviour:

Focus to work after you typed something in the text field

Observed behaviour:

Fails as soon as something was typed. The inputEl.current becomes null after you typed something.

react-mentions-focus_programmatically_fails_after_typing

Workaround:

Couldn't figure one out