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

Tagging mode broken in latest release #1693

Closed
offtopic opened this issue Jun 29, 2016 · 11 comments
Closed

Tagging mode broken in latest release #1693

offtopic opened this issue Jun 29, 2016 · 11 comments

Comments

@offtopic
Copy link

In ui-select v0.18.0 the Tagging mode is broken and causes more than 10 digest loops.
Steps to reproduce with plnkr:
http://plnkr.co/edit/SNOI0DmFDAah2AvwHseY?p=preview

  1. type "a" <Enter>
  2. type "aa"
  3. Look at the console:

VM3851 angular.js:13236 Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting! Watchers fired in the last 5 iterations: [[{"msg":"{active: $select.isActive(this), disabled: $select.isDisabled(this)}","newVal":{"active":true,"disabled":true},"oldVal":{"active":true,"disabled":false}}],[{"msg":"{active: $select.isActive(this), disabled: $select.isDisabled(this)}","newVal":{"active":true,"disabled":false},"oldVal":{"active":true,"disabled":true}}],[{"msg":"{active: $select.isActive(this), disabled: $select.isDisabled(this)}","newVal":{"active":true,"disabled":true},"oldVal":{"active":true,"disabled":false}}],[{"msg":"{active: $select.isActive(this), disabled: $select.isDisabled(this)}","newVal":{"active":true,"disabled":false},"oldVal":{"active":true,"disabled":true}}],[{"msg":"{active: $select.isActive(this), disabled: $select.isDisabled(this)}","newVal":{"active":true,"disabled":true},"oldVal":{"active":true,"disabled":false}}]]

This scenario is working with the officials samples with version v0.16.1 and within
http://plnkr.co/edit/Wa5BP8pkhH03EF0dzgrs?p=preview also with v0.16.1

@nkovacic
Copy link

nkovacic commented Jul 7, 2016

+1 Have the same issue.Occurs when new tag is created and then you start typing the same tag again.

@giovanibarili
Copy link

giovanibarili commented Jul 7, 2016

+1 Have the same issue.

@suricactus
Copy link

+1 can confirm, same issue here.

@user378230
Copy link
Contributor

Thanks for the report, we have a reproduction scenario now so we need a PR rather than +1's 😃

@akempes
Copy link

akempes commented Jul 8, 2016

When I remove the disabled: $select.isDisabled(this) from the bootstrap/choices.tpl.html template everything works fine again.

I tracked it down to the ctrl.activate function. If the ctrl.open = true; is removed the problem isn't appearing...

This is not a fix but maybe someone else can use this as a lead... I'm not familiar with the code.

@user378230
Copy link
Contributor

@akempes That's exactly what we needed! Thanks!

Here is an updated plunkr http://plnkr.co/edit/VmiHZuyebEUc5JcHayF5?p=preview

Adding a check if its a tag appears to have resolved it.

 ctrl.isDisabled = function(itemScope) {
    ...
    if (itemIndex >= 0 && (!angular.isUndefined(ctrl.disableChoiceExpression) || ctrl.multiple)) {
      item = ctrl.items[itemIndex];
      if(item.isTag) return false;
      isDisabled = !!(itemScope.$eval(ctrl.disableChoiceExpression)) || _isItemSelected(item); // force the boolean value
      item._uiSelectChoiceDisabled = isDisabled; // store this for later reference
    }
   ...
  };

Can I get confirmation this works for people?

/ping @suricactus @giovanibarili @nkovacic @offtopic

@akempes
Copy link

akempes commented Jul 8, 2016

@user378230 It's working for me! Thanks!! I just hadn't got the time to really dive into this problem...

@giovanibarili
Copy link

giovanibarili commented Jul 8, 2016

@user378230 not working

localhost-1468000642082.txt

@user378230
Copy link
Contributor

user378230 commented Jul 8, 2016

@giovanibarili are you using the updated version in my plunkr? (Not sure how you are running localhost, maybe you didn't update your local version)

It appears to work for @akempes...

@giovanibarili
Copy link

@user378230, no, i'm tested in my application. At real, my problem is occur when selected an item and digit any words.

@user378230
Copy link
Contributor

@giovanibarili you did not use my updated plunkr to test then? I updated my plunkr only... 😕

user378230 added a commit to user378230/ui-select that referenced this issue Jul 8, 2016
Resolves issue where isDisabled was running for tags and causing a
infite loop to occur if the new tag value included a previous value.

For example:
  tag1: "a"
  tag2: "aa"

Fixes angular-ui#1693
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

6 participants