signavio / react-mentions

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

Text area auto focuses on render #684

Open dominoweir opened 1 year ago

dominoweir commented 1 year ago

Steps to reproduce:

  1. Load any instance of the component
  2. Note that the text area automatically receives focus.
  3. Note that in version 4.4.7 of this package, this does not happen.

Expected behaviour:

The text area is rendered but does not automatically focus. In my use case, this is desired.

Observed behaviour:

The text area auto focuses when rendered. If the text area is not currently in view, the page scrolls until it is visible.

Workaround:

None.

This issue is already solved by #682. Can we please get this PR approved and a new release rolled out?

jovanbaj commented 1 year ago

I think you can use autoFocus={false} as a workaround, it should override it since the spread of all props happens after setting the autofocus.

// from the implementation
 <textarea autoFocus ref={this.setInputRef} {...props} />
dominoweir commented 1 year ago

I think you can use autoFocus={false} as a workaround

Thank you, this workaround did the trick for us!