tagify icon indicating copy to clipboard operation
tagify copied to clipboard

Mixed mode: output

Open raikow opened this issue 6 years ago • 7 comments

Hi,

Is there a way to receive the output in the same format than the input? may updating lastOriginalValueReported?

  1. INPUT: [[cartman]]⁠ and [[kyle]]⁠ do not know [[Homer]]⁠
  2. if i'm editing the textarea by appending a free (text, tag, go to line): "or \n marge"
  3. WISHED OUTPUT: [[cartman]]⁠ and [[kyle]]⁠ do not know [[Homer]]⁠ or\n[[Marge]]

I only managed to get outputs in:

  • free text (without /n)
  • HTML format
  • array of tags (without free text).

Did i miss something? (I'm using React)

raikow avatar Jun 17 '20 10:06 raikow

I hardly understand. What does "go to line" mean?

I am asking you - do you get this output using a regular textarea with your desired input?

yairEO avatar Jun 18 '20 07:06 yairEO

Sorry "go to line" means only to press the "ENTER" key (\n).

Let's make a more detailed example:

I have something like that in the INPUT <Tags {...props}>Camp Nou {{["id":"date","value":"Date"]}} at {{["id":"time","value":"Time"]}}</Tags> That will be rendered as "Camp Nou [Date] at [Time]"

Now I add some more information through the input (press ENTER + typing) " Rivaldo make his [Counter] goal."


For the output I have two options now:

  • onChange => Issue => Only triggered when add/remove Tag, not when writing free text
  • Access through the ref. => this.instance.tagify

But I couldn't manage to get the same output style like I had in input Camp Nou {{["id":"date","value":"Date"]}} at {{["id":"time","value":"Time"]}}\nRivaldo make his {{["id":"counter","value":"Counter"]}} goal.

instead i only got:

  • plainText (without \n) => this.instance.tagify.DOM.input.textContent
  • html => this.instance.tagify.DOM.input.innerHTML
  • tagArray (free text not included) => this.instance.tagify.value

raikow avatar Jun 18 '20 09:06 raikow

onChange event spec says this event is fired when a <textarea> looses focus. why would you need it to fire constantly on every typed character? what's the use-case?

The demo (on the README file) shows how onChange works for mixed-tags.

I don't know why you are accessing tagify.DOM.input? What had led you to the thought you need to use this to get the value you want? it's not in the documentation and you should not try getting any value from that element, it's internal to tagify.. I went get into details but the demo shows exactly how to get the output, including new lines

yairEO avatar Jun 20 '20 10:06 yairEO

Hi yairEO,

You are right (of course 😆), I hadn't noticed that it is triggered on focus/lose focus. Was thinking that it's only on tagChanged like the docs suggest.

Thanks for your help 👍

raikow avatar Jun 23 '20 07:06 raikow

Hi yairEO,

I run in the same issue today. I want to integrate tagify into a formsy form. Unfortunately the validations trigger on typing not onBlur/onFocus. That means that the message "error: xy is required" is displayed when typing in tagify.

Is there a way to get the same output format as in onChange "=> e.target.value" while doing an onKeyDown event?

raikow avatar Jun 24 '20 10:06 raikow

"Unfortunately the validations trigger on typing not onBlur/onFocus" - what validation? who is doing the validation? I don't understand what exactly your desired UX should be behave like.

yairEO avatar Jun 24 '20 10:06 yairEO

Formsy has a validation system that check every input before sending the form (onValidSubmit)

My tagify component should be required, if it's empty i display a little message below 'xy is required'. Now my issue is that formsy will check it on typing (keydown) while tagify update his value onBlur/onFocus. That means that while typing in the textarea, my m error message still remains present and will only go away when the tagify component will loss focus.


Off topic I also found an issue in the onChange function. While trying the demo page (on Firefox) I notice that when typing an "e" character in a blank line (line 6). The console output only goes until there, below is lost (in console only). Then when I clicked in the input again (give it focus) on the same line (6 with the 'e') and leave (blur) without editing the input. The output in console will be the original input (without e) Could you tell me if you can reproduce it?

raikow avatar Jun 24 '20 11:06 raikow