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

How can re-render react-grid-layout column's width on parent's resizing? not window resizing #1369

Closed
nasringh opened this issue Jan 4, 2021 · 10 comments
Labels
stale The label to apply when a pull request or an issue is stale

Comments

@nasringh
Copy link

nasringh commented Jan 4, 2021

I have a dashboard panel using react js that I used react-grid-layout in it; I used react-grid-layout in my content and that works correctly but when I close my right side or left side panels (drawers) , the width of my content that is the parent of my react-grid-layout modifies but after this changes my column's width did not modify according to their parent's width size; How can I reload my ResponsiveGridLayout component to changing the childs(columns) width?
This is simple code for showing my problem in this question example

@rajat-sf
Copy link

We are also facing similar issue. Waiting for any solution.
@nasringh have you implemented any workaround for this, if yes then let me know.
Thanks.

@yufan1029
Copy link

I have the same problem waiting to be solved.

@dtksi
Copy link

dtksi commented Jan 30, 2021

+1

@rajat-sf
Copy link

rajat-sf commented Feb 1, 2021 via email

@yufan1029
Copy link

Thank you very much. The problem has been solved.
@rajat-sf

@YashiPatel
Copy link

YashiPatel commented Feb 24, 2021

I have implemented react-grid-layout for my dashboard, it’s properly working with resize and dragged, I am used COREUI template. The problem is, when the dashboard is open with drawer and if, I can resize me window , that time drawer is close, and all grid is smaller then window size, it can not capture current size of window, then again maximize with full screen, that time drawer open and react-grid-layout can consider whole area of window it not consider size of drawer, and my whole grid is out of react-grid-layout area.
So, how can solve my problem with drawer?

@github-actions
Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this issue will be closed in 7 days

@github-actions github-actions bot added the stale The label to apply when a pull request or an issue is stale label Mar 26, 2021
@github-actions github-actions bot closed this as completed Apr 2, 2021
@zhaoqi-nb
Copy link

@yufan1029 我现在也有这个问题,请问怎么解决呢

@vincecoscia
Copy link

vincecoscia commented Feb 24, 2023

I was struggling with this issue for a while. React SizeMe didn't feel as intuitive as I wanted and wasn't yielding any results.

My side nav's "isCollaped" state is stored in context which I pass to my react-grid-layout component. Using useEffect, I dispatch a resize event to the window to force the grid to re-render. See below.

useEffect(() => {
    // when isCollapsed changes, we need to dispatch a resize event to the window to force the grid to re-render
    setTimeout(
      ()=>{window.dispatchEvent(new Event('resize'));},
      200
      );
  }, [isCollapsed]);

This still uses the ResponsiveGridLayout with the WidthProvider (The WidthProvider ONLY listens to resize events which is why this works). Another note is to change the timeout to however long it takes for your sidenav to collapse/expand. Mine is 200ms and works perfectly, but yours may be longer or shorter so keep it in mind. Hope this is more intuitive for you all!

@lakshya-sky
Copy link

import RGL from "react-grid-layout";
import { withResizeDetector } from 'react-resize-detector';

const ReactGridLayout = withResizeDetector(RGL);

function LocalStorageLayout(..){
    return <ReactGridLayout {...}>....</ReactGridLayout>
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale The label to apply when a pull request or an issue is stale
Projects
None yet
Development

No branches or pull requests

8 participants