josdejong / svelte-jsoneditor

A web-based tool to view, edit, format, repair, query, transform, and validate JSON
https://jsoneditoronline.org
Other
816 stars 108 forks source link

Adding onHover event #343

Closed TimHeckel closed 6 months ago

TimHeckel commented 7 months ago

This is a simple update to add an onHover custom event - I'd like to be able to optionally provide tooltips or something else when users hover over a node.

josdejong commented 7 months ago

Thanks for your PR Tim!

I think there is a bigger challenge here then just introducing an "onHover" (mousedown). In the same way, people may need a trigger on mouseup, mousemove, mouseover mouseout, etc, The reason that you can't add a listener on the root DIV element is the event.stopPropagation() that is used in some of the event listeners, to prevent the event from triggering recursively. Maybe we can solve that in a different way: somehow add a flag to the event or store the event internally, so that the nested JSONNode component knows the event is already handled by a child component. What do you think?

josdejong commented 6 months ago

Ping @TimHeckel any thoughts?

josdejong commented 6 months ago

I'll close this PR now due to a lack of response. Let's first discuss what the most suitable solution for this issue will be.