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

Custom drag handle not working with renderCB when using LazyLoad or React #2939

Closed
GowthamTG opened this issue Feb 8, 2025 · 3 comments · Fixed by #2940
Closed

Custom drag handle not working with renderCB when using LazyLoad or React #2939

GowthamTG opened this issue Feb 8, 2025 · 3 comments · Fixed by #2940
Labels

Comments

@GowthamTG
Copy link
Contributor

When using renderCB to render elements, custom drag handles are not functioning as expected. The drag functionality remains bound to the default .grid-stack-item-content instead of the specified custom handle.

Environments where issue occurs:

  1. HTML with lazyLoad: true (Works fine when lazyLoad: false)
  2. React (Doesn't work even with lazyLoad: false, likely due to React components mounting after GridStack initialization)

Expected Behavior:
The custom drag handle should be functional when specified in the renderCB implementation.

Current Behavior:
The drag functionality remains bound to .grid-stack-item-content instead of the custom handle.

[Please let me know if you need any additional information or specific code examples to reproduce the issue.]

Screen.Recording.Feb.8.2025.mov
@adumesny
Copy link
Member

adumesny commented Feb 8, 2025

thanks for the report but next time please post that code or a running example so I don't have to re-create it!

Image

adumesny added a commit to adumesny/gridstack.js that referenced this issue Feb 8, 2025
* fix gridstack#2939
* MakeWidget() will not call drag&drop init if lazy load - which is done after content is renderCB instead.
* added `Utils.lazyLoad()` to make it easier to check.
@adumesny
Copy link
Member

adumesny commented Feb 8, 2025

fixed in next release. as for React, we shouldn't call MakeWidget() until all DOM content has been created (if you have content custom drag handler). What I do in Angular wrapper. Otherwise you have to disable/re-enable move on the widget as _prepareDragDropByNode() is private and doesn't handle changing the handle.

don't forget to donate if you find this lib useful!

@adumesny
Copy link
Member

Update: grid.prepareDragDrop(el) is now public!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants