Skip to content

I don't think that expand() and collapse() operate in the documented manner #60

@ekuns

Description

@ekuns

Describe the bug
When I try to use viewer.expand('some.path') or viewer.collapse('some.path') both do not do what I expect. If I call viewer.expand('some.path.to.an.object') and the object exists, it does indeed expand that path. However, it also collapses all other paths that aren't that one. If I call it with a path that does not exist, then consistent with that behavior, it collapses everything.

Any call I make to viewer.collapse('any.path') with any path at all collapses everything just like collapseAll() was called, or like I called viewer.collapse('**')

Expand and collapse affect the entire JSON object and not just the path passed into them.

To Reproduce
Steps to reproduce the behavior:

  1. Create a web page (I will attach an example) that uses the library
  2. Load the web page in a browser and open DevTools
  3. Create a viewer in the DevTools console with viewer = document.querySelector('#jsonNodeId')
  4. Try to expand and collapse individual parts of the JSON in DevTools by calling expand and collapse

Link to Minimal Reproducible Example
I will attach a sample HTML file with an example

Expected behavior
I expect expand() to expand the part of the JSON object as passed in, and to not affect any other part. I expect collapse() to collapse the part of the JSON object as passed in and to not affect any other part. Instead, but affect the entire object. Collapse() and collapseAll() both act the same for me. Expand expands the requested piece and collapses all the rest.

expandAll() and collapseAll both work as expected.

Desktop (please complete the following information):

  • Win10
  • Chrome 142.0.7444.176 (Official Build) (64-bit)
  • json-viewer Version 2.1.2 from unpkg.com

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions