-
-
Notifications
You must be signed in to change notification settings - Fork 50.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The autoFocus property doesn't work for the Input component inside the Modal #41239
The autoFocus property doesn't work for the Input component inside the Modal #41239
Comments
You may look for issues: |
* chore: father4 & rc-test * chore: add husky * chore: update test --------- Co-authored-by: MadCcc <1075746765@qq.com>
temporary solution.
|
I also have a problem with this in Another solution I found is adding a ref and setting focus using
Here it is mentioned that Overall |
How to handle this elegantly, now that there is a focus on management needs. Can you only call |
1 case :
2 case
|
It is working with the ref, but only on initial open, when you close and open again it won't work |
I think doing it this way like it mentioned above, works well. (Don't use destroyOnClose in Modal)
|
I think doing it this way like it mentioned below, works well. (Don't use destroyOnClose in Modal)
|
It appears that the PR has been in a draft state for over a year. |
Wait until the modal is open and then focus. // antd v5.21.6
export function Overlay() {
const autoFocusRef = useRef<Nullable<InputRef>>(null)
return (
<Modal afterOpenChange={(open) => open && autoFocusRef.current?.focus()}>
<Input ref={autoFocusRef} />
</Modal>
)
} |
Reproduction link
Steps to reproduce
Open the modal and you see the input field is not focused
What is expected?
The input field should be focused
What is actually happening?
The input field is not focused
The text was updated successfully, but these errors were encountered: