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

Layout grid item is not made static when the "static" property of a layout is updated from false to true #1513

Closed
komoo1 opened this issue Jul 8, 2021 · 10 comments
Labels
stale The label to apply when a pull request or an issue is stale

Comments

@komoo1
Copy link

komoo1 commented Jul 8, 2021

CodeSandbox Link
https://codesandbox.io/s/practical-elgamal-h3c6y?file=/src/ShowcaseLayout.js

Steps to Recreate Issue:

  • Generate new layout and ensure that grid box 0 is not static
  • Confirm Grid Item Box 0 is draggable
  • Click the button "Update GridItem 0 to Static" to update Grid item box 0 to static in the layout
  • See that Grid box 0 is still draggable. Though the property was updated, the behavior was not.

Expectation

  • Layout Grid item should be static when the ''static'' attribute is updated from false to true
@ofekkazes
Copy link

Hi,

I have encountered the same exact issue, if the layout started with an item static, changing it's value to false will not change the GridItem's behavior, same as with isDraggable, and the same goes for if the layout has an item not static, changing the value will not change its behavior.

@adi-sekar
Copy link

@komoo1 I encountered same issue, but found a hack to fix it. The onLayoutChange 2nd parameter layouts, still holds on to the old values before the static update. You will have to update it with the new value, and set it in Redux store in my case/ react state.

@ofekkazes
Copy link

@adi-sekar this is only when onLayoutChange is triggered, if no item was repositioned or had a change of dimensions the function will not be triggered.
We can trigger a temporary position/dimension change after making items static to trigger the function, but that will also show the temporary changes on the items on React and will look "buggy".

Nevertheless it might work, and thank you for taking the time to check it.

@adisekar
Copy link

@ofekkazes Is there another event, which gets triggered if static is updated or say something like minWidth/isDraggable etc, some thing which does not affect the layout position immediately get changed?

@pietromassiccio
Copy link

Any update on this? I am encountering the same issue!

@adi-sekar
Copy link

@pietromassiccio The fix I did for this, is to
The onLayoutChange 2nd parameter layouts, still holds on to the old values before the static update. You will have to update it with the new value

@pietromassiccio
Copy link

@adi-sekar Thanks for the idea, however as @ofekkazes pointed out onLayoutChange gets fired only when the layout has changed by repositioning an item for instance.

@pietromassiccio
Copy link

@komoo1 I think it's just a bug in your code at line 75. You should be comparing against a string and not an integer. Exchange that with i === "0" and it should work.

updateGridItemStatic() { let idx = this.state.layouts.lg.findIndex((e) => e.i === 0); ... }

@ofekkazes
Copy link

For now I had used the isDraggable prop on RGL which locks the layout and is working as expected, instead of locking one item, locking every one is the best next thing :)

@github-actions
Copy link

github-actions bot commented Dec 9, 2021

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 Dec 9, 2021
@github-actions github-actions bot closed this as completed Jan 8, 2022
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

5 participants