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

Splitting on Paste only supports first token #1566

Closed
logannc opened this issue Apr 18, 2016 · 3 comments
Closed

Splitting on Paste only supports first token #1566

logannc opened this issue Apr 18, 2016 · 3 comments

Comments

@logannc
Copy link

logannc commented Apr 18, 2016

Bug description:

Splitting on pasted data only supports splitting on the first token.

Link to minimally-working plunker that reproduces the issue:

[literally any working tagging ui-select instance - see select.js ln 826]

UI-Select: 0.16.1

This isn't a bug in that the code is doing something unexpected, so much as it is unexpected that the code would be written this way. An improvement would be to iterate over splitting tokens and split on the first token that exists in the string.

@logannc
Copy link
Author

logannc commented Apr 18, 2016

For example,

for (let token of ctrl.taggingTokens.tokens) {
    var separator = KEY.toSeparator(token) || token;
    var items = data.split(separator);
    if (items && items.length > 1) {
        var oldsearch = ctrl.search;
        angular.forEach(items, function (item) {
              var newItem = ctrl.tagging.fct ? ctrl.tagging.fct(item) : item;
              if (newItem) {
                  ctrl.select(newItem, true);
              }
          });
          ctrl.search = oldsearch || EMPTY_SEARCH;
          e.preventDefault();
          e.stopPropagation();
          break; // only split by one token
    }
}

@user378230
Copy link
Contributor

Can you submit a PR for this (with relevant tests)? (Assuming you weren't going to already 😄)

@logannc
Copy link
Author

logannc commented Apr 19, 2016

Is the ES6 for (let .. of ..) syntax allowed?

torstenrudolf added a commit to itslowvoice/ui-select that referenced this issue Apr 24, 2016
use first taggingToken contained in paste data for splitting (previously only first token was used)

Closes angular-ui#1566
torstenrudolf added a commit to itslowvoice/ui-select that referenced this issue Apr 25, 2016
use first taggingToken contained in paste data for splitting (previously only first token was used)

Closes angular-ui#1566
torstenrudolf added a commit to itslowvoice/ui-select that referenced this issue Apr 25, 2016
use first taggingToken contained in paste data for splitting (previously only first token was used)

Closes angular-ui#1566
fcaballero pushed a commit to fcaballero/ui-select that referenced this issue Apr 25, 2016
use first taggingToken contained in paste data for splitting (previously only first token was used)

Closes angular-ui#1566
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants