• Resolved nastengo

    (@nastengo)


    Hi!, I would like to know how to put the search field already selected when clicking on “select2” since it is not intuitive to have to click again to search…

    you can see this on “Pais” & “Rubro…”

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support andrewshu

    (@andrewshu)

    Hello @nastengo

    Try to add this JS code to your site:

    jQuery(document).on('select2:open', () => {
       document.querySelector('.select2-search__field').focus();
     });

    Regards.

    Thread Starter nastengo

    (@nastengo)

    Thank you @andrewshu ! ❤️ that solve the problem!, maybe can solve the other problem … when i pass with tab key maybe the select search should be activated without make click or ‘enter’ in the select.

    Plugin Support andrewshu

    (@andrewshu)

    Hello @nastengo

    This is select2 js works (not the UM). You could try to use this JS code, maybe it helps:

    // on first focus (bubbles up to document), open the menu
    $(document).on('focus', '.select2-selection.select2-selection--single', function (e) {
      $(this).closest(".select2-container").siblings('select:enabled').select2('open');
    });
    
    // steal focus during close - only capture once and stop propogation
    $('select.select2').on('select2:closing', function (e) {
      $(e.target).data("select2").$selection.one('focus focusin', function (e) {
        e.stopPropagation();
      });
    });

    Regards.

    Plugin Support andrewshu

    (@andrewshu)

    Hi @nastengo

    This thread has been inactive for a while so we’re going to go ahead and mark it Resolved.

    Please feel free to re-open this thread if any other questions come up and we’d be happy to help. 🙂

    Regards

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Search Select “selected”’ is closed to new replies.