Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

Null tag added to list (race condition) #520

Closed
aeharding opened this issue Dec 16, 2014 · 5 comments
Closed

Null tag added to list (race condition) #520

aeharding opened this issue Dec 16, 2014 · 5 comments
Assignees

Comments

@aeharding
Copy link

Hi guys,

I'm happy that tagging is being added to ui-select, however, it's still pretty rough around the edges. 0.9.5 fixed a lot of the things that made it unusable (couldn't select first thing, other breaking stuff), but I've encountered another smaller issue with 0.9.5.

http://plnkr.co/edit/Yx4I7EEM7jn7XVdKqsbL?p=preview
image

Click inside the input area, and then type a comma and then hit enter very quickly (it doesn't occur when you press comma and then spacebar, for some reason). A null item will be added to the array of items, which is annoying since it causes many errors in the console, and cannot be removed by clicking the 'x' or using the delete button.

Also, why does the dropdown flicker when tagging is enabled? It's kinda annoying, and it'd be nice if that could be fixed.

I appreciate the work done here guys!

@brianfeister
Copy link

The flicker happens because the controller needs to strip the value each time you type a character and check to see if it matches items already in the list to prevent it from adding duplicates of existing select options. The delay is a necessary evil because of we need to not interfere with refresh which gives the option to populate via AJAX response, so we need to populate the ctrl.items object and then react to it.

The null object is a pretty small issue, which can be fixed by type checking inside of the ctrl.select function. How many miliseconds are we talking about here?

@NJAldwin
Copy link

I'm seeing this as well, though it's not a race condition in this case. Pressing the down arrow (to open the dropdown), then pressing the up arrow (to deselect anything), then pressing enter causes a null element to be added. The null element does not appear in the list, so it probably shouldn't be able to be selected.

dropdown with nothing selected

dropdown with a null element

Furthermore, this null element does not seem to be removable, instead throwing this:

TypeError: Cannot read property '_uiSelectChoiceLocked' of undefined
    at ctrl.removeChoice (http://run.plnkr.co/Agl9e65wEUyqtG1P/select.js:497:23)
    at getNewActiveMatchIndex (http://run.plnkr.co/Agl9e65wEUyqtG1P/select.js:609:20)
    at _handleMatchSelection (http://run.plnkr.co/Agl9e65wEUyqtG1P/select.js:625:18)
    at http://run.plnkr.co/Agl9e65wEUyqtG1P/select.js:648:23
    at Scope.$eval (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.18/angular.js:12556:28)
    at Scope.$apply (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.18/angular.js:12654:23)
    at HTMLInputElement.<anonymous> (http://run.plnkr.co/Agl9e65wEUyqtG1P/select.js:643:14)
    at http://ajax.googleapis.com/ajax/libs/angularjs/1.2.18/angular.js:2816:10
    at Array.forEach (native)
    at forEach (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.18/angular.js:320:11)

Similar behavior occurs in object-based tagging. Plunker demo

@jtomek
Copy link

jtomek commented Jan 12, 2015

I am having the same problem.

@brianfeister
Copy link

I didn't look closely at this the first time I commented on it. It's a valid bug. It's related to the internal ctrl.activeIndex property's tracking as it relates to the tagging feature. Can't promise to fix this immediately, but I'll add it to my to-do list.

@wesleycho
Copy link
Contributor

Closing as this looks like it has since been fixed. Feel free to open a new issue if it is still a problem in the latest release.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants