CarlosNZ / json-edit-react

React component for editing/viewing JSON/object data
https://carlosnz.github.io/json-edit-react/
MIT License
122 stars 13 forks source link

Make the entire node clickable #118

Closed pankajparashar closed 23 hours ago

pankajparashar commented 1 week ago

It'll be nice for the entire node to be clickable, instead of just using the Arrow icons to expand/collapse a node. Also it will make it more accessible.

Even if the library doesn't want to support this, Can you guide me how I can implement this using your library?

CarlosNZ commented 1 week ago

Thanks for the suggestion. It's not a bad idea as the current click zone is possibly a bit small, particularly on mobile devices.

It's fairly simple to add the click handler to the whole div, but making it not respond to the other click zones is a bit trickier, not to mention possible conflicts with drag and drop.

I'll need to have a think about how best to implement it so it doesn't seem confusing if you're not expecting it, but I think we can do something. Perhaps just the whole left margin could be the click zone?

Open to further discussion.

CarlosNZ commented 1 week ago

@pankajparashar What do you think of this? I've made a "click-zone" down the whole left margin of the node, as well as made the main header bar click-able for collapse:

2024-09-10 11 40 41

I think this is nicer than making literally the whole node clickable, as it's a bit more intuitive for the user and won't conflict with drag-n-drop and other clickable items (e.g. double-click to edit)

pankajparashar commented 23 hours ago

Yes I think this looks perfect! Massive thanks for adding this feature!