Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression in v0.2.7 #31

Open
shennan opened this issue Feb 1, 2024 · 4 comments
Open

Regression in v0.2.7 #31

shennan opened this issue Feb 1, 2024 · 4 comments

Comments

@shennan
Copy link

shennan commented Feb 1, 2024

There is a change in the way that auto-collapsing of objects works between version 0.2.6 and 0.2.7.

When handing it a large array, v0.2.7 auto-collapses the array into sections of 100; like so:

Screenshot 2024-02-01 at 06 47 36

Which is not great. This happens even if I set the collapseObjectsAfterLength prop to higher than 100 or remove it entirely.

Have a test yourself on this:

const obj = Array.from(new Array(250)).map((el, i) => ({ index: i, foo: 'bar', hello: false }))

<JsonView
  src={obj}
  collapseObjectsAfterLength={5000} /* This has no effect */
  enableClipboard={false}
  collapsed={false}
/>

It's worth noting that the version before (0.2.6) doesn't do this but it also doesn't respond to the collapseObjectsAfterLength property at all - so it could be that this is just an issue with displaying arrays at the root level?

If the intention is to have an absolute maximum before collapsing, then 100 is too low of a setting. In any case; some clarity in the docs would be preferable (if this is not a bug).

@YYsuni
Copy link
Owner

YYsuni commented Feb 2, 2024

I did that for imitating chrome console behavior(below) and for helping someone trouble in large array. Well, for you issue, I'd consider adding some logic.
image

@shennan
Copy link
Author

shennan commented Feb 2, 2024

Hmmm, your choice but I personally think 100 is too harsh a limit. Browser console is for debugging purposes, not for UI. Your library is for UI. I've had to go back to version 0.2.6 and if you don't plan on supporting 100+ rows without the user having to uncollapse then I'll need to move libraries.

@YYsuni
Copy link
Owner

YYsuni commented Feb 3, 2024

Don't worry, I hope I'd give you a satisfactory reply. Thanks for your issue feedback.

@YYsuni
Copy link
Owner

YYsuni commented Feb 4, 2024

@shennan new property ignoreLargeArray available in v0.2.8-canary.0, you can npm i react18-json-view@canary to use it. More information, please check https://jv.yysuni.com/ Collapsed section

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants