bvaughn / react-resizable-panels

https://react-resizable-panels.vercel.app/
MIT License
3.58k stars 124 forks source link

Handle Father Panel size inside nested Panel Group #362

Closed ItsTonyDavid closed 1 month ago

ItsTonyDavid commented 1 month ago

I was doing some nested panels. But I needed to handle the father's panel size inside the nested Panel Group.

<PanelGroup direction="horizontal">
  <Panel>
  {/* Stuff in here */}
  </Panel>
  <Panel id="father"> 
    <PanelGroup direction="vertical">
      <Panel id={child}>
      </Panel>
      <PanelResizeHandle/>
      <Panel id={child}>
      </Panel>
    </PanelGroup>
  </Panel>
</PanelGroup>

Could the Panel with ID child handle the resize of the father panel too?

bvaughn commented 1 month ago

You can do this using the panel group onLayout prop or the panel onResize prop. (You can listen to size changes and pass them down as props or context to your nested components.)