Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React | Modal input field auto focus

I'm using React and Ant Design.

I have a popover with a button. When the user clicks the button, it shows the modal with an input field.

Problem

When I click the Show Modal Button auto focus is not working and also popover is not hiding

I tried with HTML5 autoFocus

<textarea autoFocus></textarea>

But it did not work, here the code: stackblitz

like image 432
Maria Jeysingh Anbu Avatar asked Feb 28 '18 13:02

Maria Jeysingh Anbu


1 Answers

Add autoFocus={false} to your modal to reject the modal's focus management.

<Modal ... autoFocus={false}>

<textarea autoFocus={true}>
like image 113
Rosy Shrestha Avatar answered Oct 16 '22 17:10

Rosy Shrestha