Skip to content

Callback for expand / collapse actions #186

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

Open
dyennam opened this issue Apr 24, 2018 · 4 comments
Open

Callback for expand / collapse actions #186

dyennam opened this issue Apr 24, 2018 · 4 comments

Comments

@dyennam
Copy link
Contributor

dyennam commented Apr 24, 2018

Hello,
I am trying to find a way to have a callback every time the user tries to expand / collapse the view.
The problem I am trying to fix is that I have RJV show up on Material-UI Dialog view.
So when user expands the nested objects manually the view goes below the page. But If user clicks an expandAll button the view reRenders to center of page.
So is there a way i can have a call back every time the user click on expand/collapse so that i can call
window.dispatchEvent(new Event('resize')) which will cause the view to rePosition itself.

Expected View being: (When user performs expand all actions)
image

Manually Expanded it looks like: The contents at the bottom end are going below the screen.
image

Thank You

@mac-s-g
Copy link
Owner

mac-s-g commented Apr 25, 2018

@dyennam thanks for the feedback. this seems like a pretty reasonable request - but I'd like to avoid throwing events at the global scope (window). can you think of an alternative solution that would solve this issue for you?

@dyennam
Copy link
Contributor Author

dyennam commented Apr 25, 2018

@mac-s-g
Hello,
I tried adding a onClick event handler at the root element, but as you know these events did not trickle down to RJV. I am not sure about an alternative solution. In my opinion, all i would need to fix the issue would be to find a way to figure out every time user clicks anywhere on the RJV component, so that i can reposition the root view accordingly. I am open to suggestions / ideas if you have any.
Thank You

@alexanderabramov
Copy link

@mac-s-g I have a slightly different use case that also needs a collapse/expand callback. I'm trying to put RJV in a table cell in react-virtualized Table, which needs row height explicitly calculated and set. So I basically need a callback any time RJV's height might change so I can recalculate parent's height accordingly. Perhaps onToggleCollapsed, and have toggleCollapsed (/src/js/components/DataTypes/Object.js#L82) trigger that.

AtlHermanChow added a commit to AtlHermanChow/react-json-view that referenced this issue Jan 17, 2020
AtlHermanChow added a commit to AtlHermanChow/react-json-view that referenced this issue Jan 20, 2020
…k. Removed rjvId as it appears to be more of an internal id that isn't exposed to consumers.
@killjoy2013
Copy link

@mac-s-g I have a slightly different use case that also needs a collapse/expand callback. I'm trying to put RJV in a table cell in react-virtualized Table, which needs row height explicitly calculated and set. So I basically need a callback any time RJV's height might change so I can recalculate parent's height accordingly. Perhaps onToggleCollapsed, and have toggleCollapsed (/src/js/components/DataTypes/Object.js#L82) trigger that.

@alexanderabramov have you already used react-json-view with react-virtualized?

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

4 participants