tagify icon indicating copy to clipboard operation
tagify copied to clipboard

React: adding a tag with uncontrolled component

Open cosydney opened this issue 3 years ago • 5 comments

Prerequisites

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

Demo Page

React issue template: https://codesandbox.io/s/tagify-react-issue-template-forked-xr93km?file=/src/index.js

Hey,

Great package.

I'm looking for a way to have external buttons that adds tags in the input where the cursor is (if possible). Like on this screenshot:

CleanShot 2022-04-11 at 10 44 33

Since I've noticed the Tagify package is not controlled I'm having a hard time having a simple solution.

Do you have any pointers on how to do that effectively? Here is a codesandbox of what I'd like to do: https://codesandbox.io/s/tagify-react-issue-template-forked-xr93km?file=/src/index.js

Thank you so much

cosydney avatar Apr 11 '22 08:04 cosydney

is it something like in this demo?

(Put your caret somewhere and then click the button)

yairEO avatar Apr 11 '22 11:04 yairEO

@yairEO are you missing the link, I don't see the demo?

cosydney avatar Apr 11 '22 12:04 cosydney

CleanShot 2022-04-11 at 16 08 44@2x Like in this demo but mixed text and tags CleanShot 2022-04-11 at 16 10 19@2x

cosydney avatar Apr 11 '22 14:04 cosydney

Hi sorry, here's the link: https://github.com/yairEO/tagify/issues/524#issuecomment-699140465

someone asked this a few years ago also

yairEO avatar Apr 13 '22 07:04 yairEO

Hi, are you still facing this issue or may I close this one?

yairEO avatar Apr 22 '22 21:04 yairEO

Hey im still having a hard time doing this with react hooks , i dont see anything with useRef either , am i missing something?

MateoKappa avatar Jul 13 '23 21:07 MateoKappa

I gave you the solution, what is the problem? why do you need to involve React hooks in this?

You only need to attach an onClick on the button and run the example code (shown in comment's link above)

yairEO avatar Aug 20 '23 07:08 yairEO