Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

createTag broken in version >= 4.0.6 for tags longer than 2 characters #5516

Closed
oserban opened this issue May 22, 2019 · 14 comments
Closed

createTag broken in version >= 4.0.6 for tags longer than 2 characters #5516

oserban opened this issue May 22, 2019 · 14 comments

Comments

@oserban
Copy link

oserban commented May 22, 2019

I tested this code on 4.0.6 and 4.0.6 (only the releases and not the RC) and works well on 4.0.5. My usage of select2 is very simple:

$('#tags').select2({
   tags: true,
   createTag: function (params) {
      console.log("create tag", params)
     return params.term.match(/^[a-z0-9-_]+$/) ? {id: params.term, text: params.term, newTag: true} : null;
     }
});

the create tag function is fired for the first 2 characters of the tag and then stops for the rest.

@jbogdani
Copy link

The issue persists in version 4.0.7.

@kevin-brown
Copy link
Member

Can you create a jsbin that reproduces this issue?

We don't have this issue in the docs, which makes me suspicious: https://select2.org/tagging

@oserban
Copy link
Author

oserban commented Jun 3, 2019

Sorry for not providing a JS Bin in the first place. Here it is: https://jsbin.com/yunayiwodo/edit?html,console,output

The problem occurs when you try to type in tags longer than 2 characters.

@oserban
Copy link
Author

oserban commented Jun 3, 2019

After a bit of digging this seems to be related to issue #5510 and issue #5485

@silent-tan
Copy link

same problem

@mariuszkrzaczkowski
Copy link

the same problem and the same lack of solution

@lucasprogamer
Copy link

same problem

@lucasprogamer
Copy link

i install version 4.0.0 to solve problem.

@JakubSvestka
Copy link

same problem

@kevin-brown
Copy link
Member

Please see #5485 (comment) for why this still remains unsolved.

We have a jsbin for this, which is why we know the issue exists. Unfortunately we can't reproduce this issue in our current test suite, which explains why it wasn't caught earlier. If someone is willing to donate some of their time to making a unit test that reproduces this issue, I'll willing to donate some time to fixing whatever is causing the issue.

@PHPist
Copy link

PHPist commented Jun 25, 2019

This problem is related to jquery-3.4.1.js

@collimarco
Copy link

@kevin-brown Since this is a severe and widespread issue, can you consider merging the fix now? Several months have already passed. The tests can be added later.

kevin-brown added a commit that referenced this issue Jul 9, 2019
Removing this no longer breaks a unit test, and having it in here
results in the select box receiving focus unexpectedly. It's not
clear what problem this was solving, since it was manually applied
from a series of pull requests.

It claims to be fixing an issue that was specific to IE11, and I'm
willing to re-introduce that bug because there doesn't appear to be
a regression test for it, and it's breaking some critical use cases.

The goal should be to focus the search box if it would have normally
lost focus when the selection was updated.

Fixes #5485
Fixes #5516
Closes #5550
@Wolfteam
Copy link

Wolfteam commented May 19, 2020

@kevin-brown This one shoud be reopened.
In this jsfiddle: Select2
after you type 2 characters, the first option gets automatically selected

@kevin-brown
Copy link
Member

This should have been fixed in 4.0.8 with and additional level of edge case smashing in 4.1.0-beta.1 If you are still seeing this issue, please open a new ticket with additional details.

@select2 select2 locked as resolved and limited conversation to collaborators May 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

10 participants