Avoid focus in select2 fields or disable auto focus in specific fields

Avoid focus in select2 fields or disable auto focus in specific fields

Lucho_1312Lucho_1312 Posts: 30Questions: 9Answers: 0

Hi!
Is it possible to avoid the automatic focus in the first field when it is a select2 field? If that's not possible, is it possible to manually stop the autofocus for certain field?

The problem is that when I have a select2 field and I click in the edit button, the modal pops up and the select2 field gets open, which is quite annoying for the user.

Thanks!
Luciano

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    Answer ✓

    You can use the focus parameter of the form-options object to tell Editor what field (if any to focus on). If you don't want any field to be focused on then set it to null.

    Allan

  • Lucho_1312Lucho_1312 Posts: 30Questions: 9Answers: 0

    Thanks! I hadn't found that option before.

    Anyway, it's not working. Is it possible that the problem is that I'm using Editor with DataTable?

    Or maybe because my first element is a select2 field?

    Thanks!
    Luciano

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin

    Can you give me a link to the page so I can check why it isn't working please?

    Allan

  • Lucho_1312Lucho_1312 Posts: 30Questions: 9Answers: 0

    I working locally and it's quite complex to give you an example, but I made it work!

    The problem was that I was setting the formOption.focus in the Editor instance, but not in the action that opens the Edit modal.

    Moving the setting there was enough.

    Thanks! We can close this thread.
    Luciano

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin

    Super - good to hear you have it working now. Thanks for posting back.

    Allan

This discussion has been closed.