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 · 12 comments

Comments

Projects
None yet
9 participants
@oserban
Copy link

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

This comment has been minimized.

Copy link

commented May 29, 2019

The issue persists in version 4.0.7.

@kevin-brown

This comment has been minimized.

Copy link
Member

commented Jun 3, 2019

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

This comment has been minimized.

Copy link
Author

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

This comment has been minimized.

Copy link
Author

commented Jun 3, 2019

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

@farzer

This comment has been minimized.

Copy link

commented Jun 5, 2019

same problem

@mariuszkrzaczkowski

This comment has been minimized.

Copy link

commented Jun 5, 2019

the same problem and the same lack of solution

@lucasprogamer

This comment has been minimized.

Copy link

commented Jun 5, 2019

same problem

@lucasprogamer

This comment has been minimized.

Copy link

commented Jun 8, 2019

i install version 4.0.0 to solve problem.

@kuba1999

This comment has been minimized.

Copy link

commented Jun 10, 2019

same problem

@kevin-brown

This comment has been minimized.

Copy link
Member

commented Jun 10, 2019

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

This comment has been minimized.

Copy link

commented Jun 25, 2019

This problem is related to jquery-3.4.1.js

@collimarco

This comment has been minimized.

Copy link

commented Jul 9, 2019

@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

Revert unknown unit test fix
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.