josdejong / josdejong/jsoneditor
Keep expanded/collapsed state when copying from code editor to tree editor
- Dominant language
- JavaScript
- Stars
- 12.3k
- Forks
- 2.1k
- PR merge metrics
- No merged PRs in 30d
Description
Clicking the convert-right button to "copy code to tree editor" collapses all nodes in the tree editor, effectively losing information that should be preserved in the client state. On a complex JSON, selectively expanding the tree represents an investment of time and energy on the part of the user, and is an expression of user preference ("I want **this** and **this** to be expanded, while leaving everything else collapsed..."), yet this information is discarded every time the convert-right button is clicked. This would be equivalent to scrolling to the top of the code at left if you were to copy-left to convert tree into JSON, however the current editor (rightly) preserves the scroll position at left when updating the contents of the document. The ideal would be to preserve the existing client state -- to the fullest extent possible -- by storing "expanded" vs "collapsed" for every node before updating the tree, and then re-applying the expand/collapse to the new tree after update, defaulting every newly-added node to the collapsed position.
Contributor guide
Assessment
This issue has not been assessed yet.