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

Programmatically adding tags in mix-mode throws an error #709

Closed
3 tasks done
gpetrov opened this issue Dec 7, 2020 · 11 comments
Closed
3 tasks done

Programmatically adding tags in mix-mode throws an error #709

gpetrov opened this issue Dec 7, 2020 · 11 comments

Comments

@gpetrov
Copy link

gpetrov commented Dec 7, 2020

Prerequisites

  • I am running the latest version
  • I checked the documentation and found no answer
  • I checked to make sure that this issue has not already been filed

got JS error:

image

When using addTags, like:

TAGIFY.addTags([{id: "query.aa", title: "query.aa", value: "query.aa"}])

@cleversonmv
Copy link

@yairEO
Copy link
Owner

yairEO commented Dec 9, 2020

Thank you, I will fix it soon.

May I ask why do you wish to add a tag this way and not the "react" why - by updating the value prop of the Tags component?

@yairEO yairEO added the Bug label Dec 9, 2020
@yairEO yairEO changed the title Delimiters of undefined error Programmatically adding tags in mix-mode throws an error Dec 9, 2020
@cleversonmv
Copy link

Thank you, I will fix it soon.

May I ask why do you wish to add a tag this way and not the "react" why - by updating the value prop of the Tags component?

Updating by value return String empty "" in the onChange, after updating the value

@yairEO
Copy link
Owner

yairEO commented Dec 23, 2020

Still need help? on the React demo page, tagify works good when updating the value prop

@yairEO
Copy link
Owner

yairEO commented Dec 23, 2020

addTags is not meant for mix mode, sorry, I will add this to the docs

@gpetrov
Copy link
Author

gpetrov commented Dec 23, 2020

So how do you add tags programmatically in mixed mode @yairEO ? Maybe also specify insert position?

@yairEO
Copy link
Owner

yairEO commented Dec 26, 2020

There is a way, now I remember:

See my last comment here:
#524

@gpetrov
Copy link
Author

gpetrov commented Dec 26, 2020

Thanks that is nice but it is much more logical just to extend the addTags to work with mixed mode.

You can then detect if there is a caret position and use it, or insert at the end. Or if another tag is selected add after it or replace.

Such functionality should be just in the core so we shouldn't have to program it each time we need a tag inserted.

@yairEO
Copy link
Owner

yairEO commented Dec 26, 2020

what do you mean by "another tag is selected"? in what way can a tag be selected?

How important is this to your project?

@gpetrov
Copy link
Author

gpetrov commented Dec 26, 2020

Oh sorry i added this programically myself 😀 very useful though when you want to edit a specific tag in external UI - it can have a "selected" state (done with css border for example) and then user can hit some edit button

@yairEO
Copy link
Owner

yairEO commented Dec 26, 2020

I've made the adjustment, per your request, to have addTags method work in mix-mode.

Once I deploy the new version, calling addTags will add a tag to the end of the Tagify component, as the last element, if there was no previous selection by the user (focused & places the caret somewhere which isn't the end of the contenteditable).

If previous selection detected, the tag-to-be-added will be added to that selection (using the selection's range as a guide where it should be placed it)

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

No branches or pull requests

3 participants