Closed kaeon closed 1 year ago
Hi @kaeon, the button would still have focus since the user interacted with it last.
One easy implementation would be to get a ref
to the input, and call focus()
on it from inside a useEffect
with the modal's open state in the dependency array.
For the time being, I'm not sure how I feel about adding an onOpen
or onClose
prop to the modal, but might reconsider in the future.
I don't know what changed but adding autoFocus on an input field inside a modal actually works now
When opening a modal I can't get an autofocus on an input field. When I check in Chrome devtools and check "document.activeElement" I see the button that opened the modal is actually in focus.
I see a lot of solutions for bootstrap mentioning autoFocus={false} on the modal and true on the input but autoFocus is not here as a Modal propery. Any advice?