Topic: Not able to set focus on a form field on a modal
triklimops-org priority asked 2 years ago
Expected behavior Open a modal and choose a field I want to set focus, the input field would have the focus.
Actual behavior The input field does not have the focus even though I set it in the code on display of the modal
Resources (screenshots, code snippets etc.)
const modalElement = document.getElementById('my-modal')
const myModal= new mdb.Modal(modalElement )
myModal.show()
$("#field-id").focus();
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Status
Opened
Specification of the issue
- ForumUser: Priority
- Premium support: Yes
- Technology: MDB jQuery
- MDB Version: MDB4 4.20.0
- Device: Computer
- Browser: Chrome
- OS: Windows 10
- Provided sample code: No
- Provided link: No
Mikołaj Smoleński staff commented 2 years ago
Do you have any errors in the console? Are you sure the code is correct and dedicated for you version of UI KIT (MDB4 4.20.0 jQuery)? Can you recreate the issue in our snippets generator? https://mdbootstrap.com/snippets
Keep coding!