boneskull / angular-tags

Pure AngularJS tagging widget with typeahead support courtesy of ui-bootstrap
MIT License
133 stars 32 forks source link

Double inputs #17

Open ravinggenius opened 10 years ago

ravinggenius commented 10 years ago

When adding a new tag, the text I type shows twice. I inspected the DOM in Chrome and noticed that two <input />s where present. I believe this issue may be related to #16. Both inputs show and are databound to the model, so when a user types in one, it shows up in both places. Obviously this will be confusing. After typing a tag in either <input /> and Enter, the tag appears to be created as normal, and only one styled tag is show.

screen shot 2013-10-18 at 11 25 20

screen shot 2013-10-18 at 12 34 38

In my view:

<tags data-options="{addable: true}" typeahead-options="typeaheadOpts" data-model="document.tags"></tags>

Inspected input DOM:

<input ng-if="!srcTags.length" type="text" data-ng-model="inputTag" class="decipher-tags-input ng-valid ng-dirty" />

<input ng-if="srcTags.length" type="text" data-ng-model="inputTag" class="decipher-tags-input ng-valid ng-dirty" data-typeahead="stag as stag.name for stag in srcTags|filter:$viewValue|orderBy:orderBy" data-typeahead-input-formatter="" data-typeahead-loading="" data-typeahead-min-length="" data-typeahead-template-url="bower_components/bootstrap/template/typeahead/typeahead-popup.html" data-typeahead-wait-ms="" data-typeahead-editable="" data-typeahead-on-select="add($item) &amp;&amp; selectArea() &amp;&amp; typeaheadOptions.onSelect()" />
boneskull commented 10 years ago

Yes, I believe this is some sort of problem related to #16. Once I confirm we can close this.

lefnire commented 10 years ago

Also having this problem on master. You can see the issue here (codepen), enter "lamb", hit and you get it twice

lefnire commented 10 years ago

Sorry, just realized mine's a bit different. If you have {addable:true} in options, it's worse: when you hit ENTER that second input tag gets added:

screen

Likely due to the same issue though, so I'll keep convo here unless I should create a new ticket.

lefnire commented 10 years ago

Seems to do with the $timeout here. When I remove it like so, it's fixed. I'm obviously missing something that's gonna bite me soon, since that $timeout was put there to patch something going on in typeahead.

boneskull commented 10 years ago

I hope to have this corrected in 1.0.0, but I'm still trying to get grunt-bowerspawn working properly.