Focus doesn't seem to be working

Wappler: 4.0.2
OS: MacOS
Server: PHP

I have a modal containing a form and I want the first field (a normal input field) to have the focus when the modal is shown but I can’t get it to work. This is the code for the modal:

<div class="modal fade" id="modalAddEngineer" is="dmx-bs5-modal" tabindex="-1" nocloseonclick="true" dmx-on:hide-bs-modal="serverconnectformAddEngineer.reset()" dmx-on:show-bs-modal="serverconnectformAddEngineer.inp_engineerFirstName.focus()">

Is it a bug or am I going about it the wrong way?

You need to use the shown event, not the show one.

1 Like

I thought it was probably me doing something wrong!

Just to help me in the future - what’s the difference between show and shown?

Explanation from Bootstrap docs:

So you want to use shown here, as you want to wait for the modal to load and become visible then focus the field.

1 Like

Brilliant. Makes perfect sense.

Thanks for the mega quick solution. :slight_smile:

1 Like