React | Modal input field auto focus

Maria Jeysingh Anbu picture Maria Jeysingh Anbu · Feb 28, 2018 · Viewed 14.2k times · Source

I'm using React and ant design for my project.

There I have a Popover and It has a button. when user click the button It shows the modal with 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. I have full code on stackblitz

Answer

Rosy Shrestha picture Rosy Shrestha · Dec 6, 2018

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

<Modal ... autoFocus={false}>

<textarea autoFocus={true}>