Closed gregsadetsky closed 4 months ago
Hi! Thank you for the fix and suggestion!
I think some users may stil want to just select the field name with double click (for instance to copy it).
So it would be good to support both use cases with expandableLabel
style and fallback to the label
when first is not set. And make expanding by click on the field name optional as well.
hey, I just took a stab at implementing this in #27 -- feel free to leave comments here or in the PR. I took liberty with the naming (clickToExpandNode
for the optional prop and clickableLabel
for the style class) -- but obviously let me know what makes sense
I also added tests and was glad to keep the test coverage at 100% :-) cheers!
Thanks! just merged and released version 1.4.0 👍
thank you!!
me again :-)
a small thing that I noticed is that expanding nodes can be done by clicking the arrow, or the collapsed
{ ... }
block, but it's not possible to expand a node by clicking the key name. see video below.I made a small change locally to this line so that instead of
{field && <span className={style.label} >{field}:</span>}
it reads
{field && <span className={style.label} onClick={toggleExpanded}>{field}:</span>}
and that does exactly what I'm looking for:
there are some small styling issues with this though:
<span>
doesn't havecursor: pointer
, which would be useful to make it clear that the node can be clickeduser-select: none
-- this is probably optional (and would also introduce a weird inconsistency in that some nodes' text would not be selectable, while others would be)I'd be happy to contribute a fix -- would you prefer a new style to be created, something like
expandableLabel
, and that (based onlabel
) would have thecursor:pointer
declaration..?thank you!