tagmanager icon indicating copy to clipboard operation
tagmanager copied to clipboard

onlyTagList not working in conjuction with typeahead.js

Open warroyo opened this issue 10 years ago • 18 comments

when trying to use the "onlyTagList" option while also using typeahead.js it is still allowing creation of new tags. I believe this has to do with the following:

   // check if restricted only to the tagList suggestions
            if (opts.onlyTagList && undefined !== opts.tagList ){

the opts.tagList option when logged in the console is always null. so it is being caught immediately.

warroyo avatar Apr 07 '14 20:04 warroyo

Same thing, it is not working at all

echochristopher avatar Jun 17 '14 23:06 echochristopher

Did you guys find a workaround by chance?

seanahrens avatar Sep 23 '14 11:09 seanahrens

Same problem here. The tagList var does not consider the values returned by typeahead.js. This needs to be fixed.

titos1 avatar Oct 01 '14 01:10 titos1

I think this is working properly on my site actually, but can check in a few days.

​The UI doesn't allow anything but type ahead selected values to be input. 

On Wednesday, Oct 1, 2014 at 9:18 AM, titos1 [email protected], wrote:

Same problem here. The tagList var does not consider the values returned by typeahead.js. This needs to be fixed.

— Reply to this email directly or view it on GitHub.

seanahrens avatar Oct 01 '14 01:10 seanahrens

It can't work, because of the code quoted above. The allowed values must be specified in the tagList option, which is not populated anywhere in the code by typeahead.js

titos1 avatar Oct 01 '14 11:10 titos1

Ah, for me, my typeahead endpoint is restricting the values to the set I need itself, so perhaps I can't comment on this issue. I'm just turning off free input, not using a local js array to restrict input.

seanahrens avatar Oct 03 '14 06:10 seanahrens

Hmm any fix for this? Wouldn't it be possible to add a validation function that checks the tag against the same tag source as typeahead? Or is there a way to manually specify the allowed values for the tagList option? EDIT: I set my taglist array as a global var and used it for the taglist option and got it working.

hessius avatar Oct 31 '14 02:10 hessius

Hey @max-favilli and @johnnyshields are there any plans on fixing this issue? Is it even acknowledge as an issue? Thanks :)

titos1 avatar Nov 02 '14 20:11 titos1

@hessius could you provide us some sample code ? thanks

rebornishard avatar Nov 05 '14 20:11 rebornishard

in the config of the tagsmanager initiation add tagList: yourTagListVariable,

So as long as typeahead adds something thats in the taglistvariable array tagsmanager will accept it

hessius avatar Nov 05 '14 22:11 hessius

Does yourTagListVariable contain every possible value the typeahead might return?

How's this solving the problem?

titos1 avatar Nov 06 '14 00:11 titos1

Yes. I'm passing the same array to tags manager as I am to type ahead. Thus I'm basically doing manually what's broken in this issue i.e. I get exclusion of values not in the array, thus "fixing" the issue in one line of code.

If one had for example a type ahead array with datums one would need a separate array of just the displayed text to pass to tm

hessius avatar Nov 06 '14 08:11 hessius

I don't think this is an acceptable solution though. The typeahead's job is to filter and get only a subset of all the possible items, based on the (partial) user input. The full set might contain millions of items. It is just not practical to pre-populate an array with all of these. A subset is supposed to be fetched based on user input.

titos1 avatar Nov 06 '14 11:11 titos1

Yes but as far as I understand that is not what this does in any situation. This checks the user entry regardless of usage of typeahead's suggestions. Thus it needs to check the whole list of possibilities. And since it just iterates over the array once even if it would contain millions of entries it wouldn't take more than a few ms Source: http://benhollis.net/blog/2009/12/13/investigating-javascript-array-iteration-performance/

hessius avatar Nov 06 '14 11:11 hessius

This is what TagManager v2 used to do.

titos1 avatar Nov 20 '14 17:11 titos1

I see this issue raised quite a few times, and it is still an issue in the current version

For example, it is said to be fixed in #171

Raised in #118, #164, #191, and the aforementioned issue too.

GRMule avatar Aug 31 '16 02:08 GRMule

Any update on this? V2 works as it should but this version and the latest Typeahead does not...

ventil8 avatar Mar 30 '17 18:03 ventil8

still no update on that issue? Not sure if there is a quick workaround?

vgross avatar May 14 '19 12:05 vgross