selectize.js icon indicating copy to clipboard operation
selectize.js copied to clipboard

Loosing focus on the field if addItems method is used

Open jf-cbd opened this issue 1 year ago • 0 comments

I did:

  • [x] Search for if my issue has already been submitted
  • [x] Make sure I'm reporting something precise that needs to be fixed
  • [x] Give my issue a descriptive and concise title
  • [x] Create a minimal working example on JsFiddle or Codepen (or gave a link to a demo on the Selectize docs)
  • [x] Indicate precise steps to reproduce in numbers and the result, like below

Steps to reproduce:

  1. In the following CodePen, when a key is released on an input field, it performs addItem on the selectize.
  2. Try typing a key in the input. The option is added, focus is still on the input field.
  3. Replace the selectize.addItem(optionValue, true); by selectize.addItems([optionValue], true)
  4. Try typing a key in the input. The option is added, but focus is lost on the input field.

Example : https://codepen.io/grandroot/pen/dyEYVVW

Expected result: Still have the focus on the input

Actual result: Loosing focus

Workaround : Replace me.addItems(aSelectedItems, true); By aSelectedItems.forEach(function(item) { me.addItem(item, true); });

Additional info : Problem happened after migrating from Selectize 0.12.4 to 0.15.2

jf-cbd avatar May 16 '24 14:05 jf-cbd