React-grid-layout: autoSize for Grid Item?

Created on 2 May 2018  路  4Comments  路  Source: STRML/react-grid-layout

Thanks for submitting an issue to RGL!

Please mark the type of this issue:

  • [ ] Bug
  • [* ] Feature Request
  • [* ] Question

There is autoSize for Grid Layout.

// If true, the container height swells and contracts to fit contents
autoSize: ?boolean = true,

Is there the same for Grid Item? I don't want to set height manually. I want Grid Item to adjust automatically to its content height. How to enable it?

Most helpful comment

Is there no way to get it to do this? I'm thinking about a Grid Item containing a <textarea /> that can grow vertically as you're typing.

All 4 comments

No, it doesn't do that.

Is there no way to get it to do this? I'm thinking about a Grid Item containing a <textarea /> that can grow vertically as you're typing.

Is there no way to get it to do this? I'm thinking about a Grid Item containing a <textarea /> that can grow vertically as you're typing.

I've written my own height layer hoc for the components inside of the GridItem that adjusts the height after the initial render.

I cannot open source it currently, as it's internal and still a bit wonky under a few conditions. However, the gist of it is that you set a ref on the component, calculate the child element heights including padding, margins via *.offsetHeight and window.getComputedStyle(<your node here>) and just send it back to wherever you keep the layout state and adjust it there.

Hope this helps. I'll open source the component once I'm done with it completely.

@TheImpressionist Any news on this ?
When I put a TextArea in the grid it doesn't resize the grid when it (the textarea) grows, it just slides under any components that are beneath it.

I'll try to work with your 'gist' but It might just a bit out of my league

Thanks

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sasha240100 picture sasha240100  路  3Comments

uditdubey picture uditdubey  路  3Comments

gfafei picture gfafei  路  3Comments

MaksZhukov picture MaksZhukov  路  3Comments

Francismb picture Francismb  路  4Comments