Autoselect option on barcode scanner input

Hello,

I started using Select2 instead of a regular <select> because of its better usability and collapsible groups, but I’ve run into one issue I can’t solve.

I need the selects to give users flexibility: besides selecting manually, they should also be able to automatically select an option after scanning a barcode into the focused and closed Select2.

With a regular <select>, this works perfectly. But with Select2, the behavior is different.

Current behavior with Select2:

  1. Select2 gets focus (but stays closed).
  2. Barcode scan input only opens the Select2 dropdown.
  3. need to scan again to search.
  4. The user must then manually confirm the selection.

Desired behavior with Select2:

  1. Select2 gets focus (single-selects).
  2. On a barcode scan, the corresponding option should be automatically selected immediately (without requiring an extra scan or manual click).

For now, I’ve reverted back to using a regular <select> because it allows “autoselect” with any event.
But i am looking forward to be able to use Select2.

Awaiting any help or suggestions.