json-edit-react icon indicating copy to clipboard operation
json-edit-react copied to clipboard

show Copied to clipboard tooltip message

Open Neica opened this issue 4 months ago • 3 comments

Suggestion

I was wondering if there is a way we can have a tooltip showing "Copied!" or "Copied to clipboard!" when a user click on the copy icon. Use case

this will help accessibility and help the user knows the field has been copied and they don't have to double click to "make sure"

Neica avatar Sep 04 '25 14:09 Neica

You can pass a function to the enableClipboard prop to provide any type of notification you like :)

See the demo for an example, which uses Toast notifications.

Here's the relevant documentation: https://carlosnz.github.io/json-edit-react/

CarlosNZ avatar Sep 04 '25 20:09 CarlosNZ

I'm not using Toast Notifications. I just have a normal tooltip component and would like to render that only for the fields that was copied.

Neica avatar Sep 05 '25 19:09 Neica

Hi @Neica, I'm not quite sure what you mean. What do you mean "a normal tooltip component"? Do you mean the tooltip that shows up in the component when you hover over a button? If so, changing the value of that won't cause it to re-render, and it's not standard usage to update tooltip content dynamically like that.

The intention of the enableCliboard callback is so you could provide any kind of feedback you like without this component needing to be opinionated about it.

CarlosNZ avatar Sep 12 '25 04:09 CarlosNZ