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

OnClick event is not firing #2092

Open
last-Programmer opened this issue Oct 14, 2024 · 5 comments · May be fixed by #2108
Open

OnClick event is not firing #2092

last-Programmer opened this issue Oct 14, 2024 · 5 comments · May be fixed by #2108

Comments

@last-Programmer
Copy link

Describe the bug

When i attach onlick event to grid item it is not firing on onclick.

This was working with version 1.4.2. From version 1.4.3 on wards it is not working. Please see the attached sand box.

Your Example Website or App

https://codesandbox.io/p/sandbox/zealous-platform-jffkrw

Steps to Reproduce the Bug or Issue

Go to the attachd sand box and click on a item and you can see that the click event is not firing.

Expected behavior

When the user clicks the item a messagebox has to be displayed but it is not firing the click event on the grid item.

react-grid-layout library version

1.5.0

Operating System Version

Windows

Browser

Chrome

Additional context

No response

Screenshots or Videos

No response

@l-bianchi
Copy link

You can use draggableCancel in the area where you need the click to happen to disable the drag event.

// A CSS selector for tags that will not be draggable.
// For example: draggableCancel:'.MyNonDraggableAreaClassName'
// If you forget the leading . it will not work.
// .react-resizable-handle" is always prepended to this value.
draggableCancel: ?string = '',

@last-Programmer
Copy link
Author

last-Programmer commented Oct 22, 2024

@l-bianchi how does it was working with version 14.2 i need both click and drag should work on grid item.. we are displaying menus as tiles and let the user rearrange the items by drag and drop. and also when clicks on the item we navigate to different page. Is there not a way to make both drag & click works on whold grid item as in 1.4.2. thanks

@l-bianchi
Copy link

I had an issue similar to yours where my buttons in the draggable item where not clickable because of the drag event and i fixed it by setting the buttons area as draggableCancel. If you need the whole area to be clickable I imagine it to be a bigger issue because you need to discriminate between the drag start and the click. Maybe in the onDragStart event you can implement some custom logic to recognize the click.
If that is not possible I would suggest a rollback to a version where it was working. Good luck!

@last-Programmer
Copy link
Author

i have already solved via hacking drag events ondragstart, ondrag and ondragend. since it was working with 1.4.2 i was wondering why the behaviour is changed with new version.

@francho-plain
Copy link

Same here. I roll back to 1.4.2 because I need both (click&drag) in my dashboard widgets.
An option to configure this could be great.

@last-Programmer: can you paste your custom events?

tessov added a commit to tessov/react-grid-layout that referenced this issue Dec 24, 2024
@tessov tessov linked a pull request Dec 24, 2024 that will close this issue
14 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants