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

In mixed mode adding and removing tags leave spaces #983

Open
gpetrov opened this issue Feb 13, 2022 · 5 comments
Open

In mixed mode adding and removing tags leave spaces #983

gpetrov opened this issue Feb 13, 2022 · 5 comments

Comments

@gpetrov
Copy link

gpetrov commented Feb 13, 2022

When using mixed mode, an extra space is always added behind the tag when added with addTags or addMixTags.
The problem is also when the tag is removed after that, the space remain. so you eventually end up with a lot of spaces,
Sometimes it might be convenient to add a space - but it should be also auto cleared. Maybe add an option to auto add space or not on tag insert.

Also by rapidly adding and deleting tags, a Zero Width Space (8203) seems to get left sometime in the code,. So a clean up when synching to the underlying textarea might be needed.

Second problem is that, again in mixed mode, there is always an enter (\n) generated at the end - even if no enter was used. This happen when using Tagify bound to a textarea.

So to solve this we have to clean the last enter each time, but then we don't know if the user maybe really pressed an enter and want to keep it.

@gpetrov
Copy link
Author

gpetrov commented Feb 13, 2022

Here is a codepen showing the issue:
https://codepen.io/gpetrov/pen/YzExeLq

result:

tagify_bug.mp4

@yairEO
Copy link
Owner

yairEO commented Feb 14, 2022

The extra space after a tag comes from this setting and I am expecting the user to see a space was automatically added after the tag, and also to remove that space if a tag was removed. I can remove that space for the user if a tag was deleted.

There are TONS of browser bugs related to contenteditable which Tagify is constantly "fighting".
Some bugs are extreme difficult to bypass...

@gpetrov
Copy link
Author

gpetrov commented Feb 14, 2022

Thanks that setting helps for the tags indeed. Maybe add it to the docs as well.

What about the automatically added \r\n at the end? Even if no new line is typed?

image

Adjusted the codepen to show it

@yairEO
Copy link
Owner

yairEO commented Feb 14, 2022

Well, \r\n shouldn't hold you back since it can be cleared before/after sending it to the server so it isn't urgent for me to work on this, because it might be very difficult. There are so so many edge cases to cover here..

@gpetrov
Copy link
Author

gpetrov commented Feb 14, 2022

Actually I narrowed it down.

When Tagify is inited with textarea it adds an extra \n to the value when user types something and the change event happen.

When later on the textarea.value is set directly and change event is triggered - there is no extra \n

I solved it currently by triggering a custom change event that doesn't clear the \n on direct change.

So it is ok for me. All good!

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

No branches or pull requests

2 participants