React-grid-layout: Wrong behaviour of onLayoutChange for responsive

Created on 30 Apr 2018  路  1Comment  路  Source: STRML/react-grid-layout

onLayoutChange returns wrong value for layout when responsive.

Suppose I have this layout. Two grid items in every breakpoint.
Suppose current breakpoint is lg

layout = {
    lg: [{}, {this item}], // watch this grid item below
    md: [{}, {this item}],
    xs: [{}, {this item}], 
    xxs: [{}, {this item}], 
    sm: [{}, {this item}]
}

If I remove a grid item in current breakpoints lg, guess what I get in a callback. For some reason onLayoutChange removes an item ONLY for current breakpoint and doesn't touch it for other breakpoints:

layout = {
    lg: [{}], // BOOM! Grid item is removed here, but still exists in all other breakpoints.
    md: [{}, {this item}],
    xs: [{}, {this item}], 
    xxs: [{}, {this item}], 
    sm: [{}, {this item}]
}

Screenshot. Do you see lg is 2 and all others are 4?

screenshot from 2018-04-30 16-46-04

This is WRONG and error prone. If I remove a grid item in one breakpoint, it has to be removed for all other breakpoints! Otherwise we end up having gazillion useless layouts for grid items we don't have already.

Most helpful comment

@wzup, this is open source software free for use and free for modification. Please check your tone at the door.

Whether or not you actually want to remove an item for all breakpoints or not is really a decision best left up to the application, not the library. You can modify all other layouts yourself via the reference if you like.

>All comments

@wzup, this is open source software free for use and free for modification. Please check your tone at the door.

Whether or not you actually want to remove an item for all breakpoints or not is really a decision best left up to the application, not the library. You can modify all other layouts yourself via the reference if you like.

Was this page helpful?
0 / 5 - 0 ratings