Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pasted text separated with new line symbol doesn't process correct #267

Closed
nikbo opened this issue Jun 26, 2019 · 16 comments · Fixed by #360
Closed

Pasted text separated with new line symbol doesn't process correct #267

nikbo opened this issue Jun 26, 2019 · 16 comments · Fixed by #360
Labels

Comments

@nikbo
Copy link

nikbo commented Jun 26, 2019

I have the latest version (2.22.3) and I have a code to initialize tagify:

this.tagify = new Tagify(emails, {
                delimiters          : ",| |:", 
                suggestionsMinChars : 3,
                maxTags             : 100,
                keepInvalidTags     : true,
                duplicates: false
            }
        );

If I paste lines like these, separated by new line symbol ('\n'):

example@fake.com
example2@fake.com
example@fake.com
example3@fake.com

And then click enter - it doesn't process text in a correct way:
Screen Shot 2019-06-26 at 12 10 50
As you can see it adds "||" symbols.

Pasting works fine if I paste text separated by comma or whitespace.

Thanks.

@yairEO yairEO added the Bug label Jun 26, 2019
@yairEO
Copy link
Owner

yairEO commented Jun 26, 2019

Thanks for reporting, I'll fix it asap

@yairEO yairEO closed this as completed in f77ad60 Aug 17, 2019
@yairEO
Copy link
Owner

yairEO commented Aug 17, 2019

Updated Tagify version to fix this v2.24.0.

You should write your Regex as so:

{
  delimiters : ",| |:|[\\n\\r]"
}

@keksa
Copy link
Contributor

keksa commented Nov 27, 2019

Hello @yairEO, we have exactly the same problem with v2.31.6. Is there any chance of regression with this bug?

This input does not work:

fd:97:30:9b:66:70
b5:b4:e6:cc:6b:de
01:1b:75:84:c2:2f

This one works just fine:

fd:97:30:9b:66:70,
b5:b4:e6:cc:6b:de,
01:1b:75:84:c2:2f

The settings can be just to reproduce:

{
    delimiters: ",| |[\\n\\r]"
}

@yairEO
Copy link
Owner

yairEO commented Nov 27, 2019

@keksa - I will check and let you know

@yairEO
Copy link
Owner

yairEO commented Nov 27, 2019

Related - #160 (comment)

@keksa - try this

@keksa
Copy link
Contributor

keksa commented Nov 28, 2019

Hi @yairEO, I tried and it does not help at all.

First, I now understand this issue #268. The problem is, that with the delimiters now being a regexp (instead of list of characters), the this.settings.delimiters.source.charAt(1) will return |, which will not match as delimiter, because it is not one of delimiters.

Second, even if I change the code to use , (just for debug) instead of the charAt(1), which is a valid delimiter in my case, it will still not process the pasted text correctly. Instead of creating 3 tags, it creates a single invalid tag with everything squashed together.

@yairEO
Copy link
Owner

yairEO commented Nov 28, 2019

@keksa - ok, I see there is a bug with the CSS of the input element itself (within Tagify) and will issue a fix asap (hopefully today I will be releasing a major version)

For now, keep your delimiters setting:

delimiters: ",|[\\n\\r]"

yairEO added a commit that referenced this issue Nov 28, 2019
- fixed #267 - Pasted text separated with new line symbol doesn't process correctly
- fixed #356 - addTags not working on mix-mode
@keksa
Copy link
Contributor

keksa commented Dec 2, 2019

Hello @yairEO, I tried grabbing the code from the v3 branch and the newline paste still does not work even after the CSS fix.

Works properly with commas, copy & paste of

fd:97:30:9b:66:70,
b5:b4:e6:cc:6b:de,
01:1b:75:84:c2:2f

results in:
comma

Does not work without commas, copy & paste of:

fd:97:30:9b:66:70
b5:b4:e6:cc:6b:de
01:1b:75:84:c2:2f

results in:
not-comma

The configuration is reduced to just this for testing:

var tagify = new Tagify(
    document.querySelector('.js-inventory-mac-addresses'),
    {
        delimiters: ",|[\\n\\r]",
    }
);

@yairEO yairEO mentioned this issue Dec 12, 2019
Merged
yairEO added a commit that referenced this issue Dec 12, 2019
- do not add multiple   after the last tag, in mixed-mode (happens if initial input value has multiline)
- re-wrote "replaceTextWithNode" method completely and renamed it "replaceTextWithNode"
- fix bug where unintended mixed-mode prefixes are removed instead of only the one needed
- fix bug with mixed-mode dropdown not removed when Tagify de-focus
- Changes to "autoComplete" setting. added "rightKey" sub-setting
- when dropdown is shown, pressing ESC key should not create a new tag, but only hide the dropdown
- improve the auto-comeplete setting with sub-settings for "enter" & "right" keys functionality (issue #103)
- on fuzzy-search, only auto-complete the input with terms starts with the typed text
- added loader animations to the CSS and "loading" method to Tagify
- single-value select mode refactoring
- demo page - suggestion list as tags that when clicked add the clicked tag
- renamed jQuery event "remove" to "removeTag" #222
- make demo page header fixed to top
- all triggered events return the instance's scope (tagify)
- add methods to the README (replaceTag)
- improved CSS dropdown animations (on show)
- Show dropdown suggestions list on arrow down #333
- fixed #267 - Pasted text separated with new line symbol doesn't process correctly
- fixed #356 - addTags not working on mix-mode
- add boolean property to "this.dropdown" that would tell if the dropdown is shown or not
- show suggestions dropdown when editing a tag
- add event: "edit:keydown"
- new event: "edit:input"
- new event: "edit:change"
- new event: "edit:start"
- added dropdown ability to use css effects when showing
- dropdown auto-adjusts its placement if there's no space for it at the bottom, it will flip to be above
@yairEO
Copy link
Owner

yairEO commented Dec 12, 2019

Just released version 3.0.0 so this should work. Try updating Tagify and check

@keksa
Copy link
Contributor

keksa commented Dec 17, 2019

Hi @yairEO, sorry to say it still does not work. Same settings as above, same data, Tagify updated to 3.1.0.

@yairEO
Copy link
Owner

yairEO commented Dec 17, 2019

GIF

copy-pasted your exact text from your comment and it works fine.

BUT now I see the problem is only with Firefox. Do you happen to use Firefox and not say it all this time..? :)

@yairEO yairEO reopened this Dec 17, 2019
@keksa
Copy link
Contributor

keksa commented Dec 17, 2019

@yairEO I use Firefox as primary browser and it was where I first noticed the problem. However I tried in Chrome (latest version) with the exact same code I posted and Tagify 3.1.0 and it did not work as well, behaved exactly the same as Firefox.

I'm on macOS, so maybe that could be the issue? I'll try tomorrow when I get back to office and let you know. Also I'm always pasting with keyboard shortcuts (cmd+v), possibly it could make a difference as well?

@keksa
Copy link
Contributor

keksa commented Dec 18, 2019

Hello @yairEO, it works in Chrome, I think I may have screwed up a little when I was trying it and only used the new JS, but not CSS and since the fix was in CSS, it did not work.

However it still does not work in Firefox, could you please look into that? 🙂

@yairEO
Copy link
Owner

yairEO commented Dec 18, 2019

I fixed it and will release the new version today. it's totally fixed so don't worry.

I just prepared a big release with many other fixes issues and a few new features and am testing things now

yairEO added a commit that referenced this issue Dec 18, 2019
@yairEO yairEO closed this as completed in af063f5 Dec 18, 2019
@yairEO
Copy link
Owner

yairEO commented Dec 18, 2019

Please try v3.2.0

@keksa
Copy link
Contributor

keksa commented Dec 18, 2019

@yairEO It works! Thank you very much.

yairEO added a commit that referenced this issue Dec 19, 2019
yairEO added a commit that referenced this issue Dec 20, 2019
* bumps package version
* changes to how the focus and dropdown reacts when clicking on the component several times in a row (and also on internal children, like a Tag or the input)
* minor renaming
* removing old code no longer needed

* Improved html minifier method
* Greatly improved mouseover dropdown items highlight speed

* Bugfix - after selecting an item from the dropdown menu, clicking the ArrowRight will continuously add the last highlighted option again

* fixed placeholder in mix-mode not being vertically well-placed

* fixes #366

* fixes #367

* updated README

* fix: mix-mode: starting to write a NEW tag and then clicking leftArrow and then Enter to select an option from the list will fail

* fix: improved accuracy of dropdown position by rounding top & bottom values

* fixes #267

* fixes ##362 (hopefully)

* bumps package version

* Partial fix: Firefox does not allow deleting tags in mix-mode
* added ability to listen/remove multiple events, for the same callback

* fixes #369

* added "getCSSVars" to read Tagify CSS variables (at least ones that matter)

* fixes #369
* added "tagify--noTags" class to the main scope when needed
* "invalid" event is now triggered *after* the invalid tag has been added to the DOM
* added "getCSSVars" method which for now only reads the (new) "--tag-hide-transition" CSS variable and parses it, so the value is used in the "removeTag" method as timeout duration.

* on mix-mode when "dropdown.enabled" is "0" do not show the suggestions dropdown when double-clicking the input. This is undesirable in mix-mode since it's not assumed the user wants to add any tags at all.

* Firefox fix for placing the caret at the end of the input when the last child is a tag element
yairEO added a commit that referenced this issue Dec 20, 2019
* bumps package version

* - changes to how the focus and dropdown reacts when clicking on the component several times in a row (and also on internal children, like a Tag or the input)
- minor renaming
- removing old code no longer needed

* - Improved html minifier method
- Greatly improved mouseover dropdown items highlight speed

* Bugfix - after selecting an item from the dropdown menu, clicking the ArrowRight will continuously add the last highlighted option again

* fixed placeholder in mix-mode not being vertically well-placed

* fixes #366

* - fixes #367
- updated README

* fix: mix-mode: starting to write a NEW tag and then clicking leftArrow and then Enter to select an option from the list will fail

fix: improved accuracy of dropdown position by rounding top & bottom values

* fixes #267

* fixes ##362 (hopefully)

* bumps package version

* - Partial fix: Firefox does not allow deleting tags in mix-mode
- added ability to listen/remove multiple events, for the same callback

* -

* fixes #369

* added "getCSSVars" to read Tagify CSS variables (at least ones that matter)

* - fixes #369
- added "tagify--noTags" class to the main scope when needed
- "invalid" event is now triggered *after* the invalid tag has been added to the DOM
- added "getCSSVars" method which for now only reads the (new) "--tag-hide-transition" CSS variable and parses it, so the value is used in the "removeTag" method as timeout duration.

* bumps package version

* - version bump

* - on mix-mode when "dropdown.enabled" is "0" do not show the suggestions dropdown when double-clicking the input. This is undesirable in mix-mode since it's not assumed the user wants to add any tags at all.

- Firefox fix for placing the caret at the end of the input when the last child is a tag element

* bumps package version

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

Successfully merging a pull request may close this issue.

3 participants