1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-11 00:08:30 +01:00

fix: improve drag behaviour when using handle (#2407)

Fixes a small bug that caused the item to be draggable when clicking
outside of the handle, when using a handle. Basically resets the
draggable state when (re)entering the container.
This commit is contained in:
Nuno Góis 2022-11-14 08:25:20 +00:00 committed by GitHub
parent 29da625195
commit bd686eb246
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -74,6 +74,9 @@ const addEventListeners = (
handleEl.addEventListener('mouseenter', onMouseEnter);
handleEl.addEventListener('mouseleave', onMouseLeave);
if (handle) {
el.addEventListener('mouseenter', onMouseLeave);
}
el.addEventListener('dragstart', onDragStart);
el.addEventListener('dragenter', onDragEnter);
el.addEventListener('dragover', onDragOver);
@ -82,6 +85,9 @@ const addEventListeners = (
return () => {
handleEl.removeEventListener('mouseenter', onMouseEnter);
handleEl.removeEventListener('mouseleave', onMouseLeave);
if (handle) {
el.removeEventListener('mouseenter', onMouseLeave);
}
el.removeEventListener('dragstart', onDragStart);
el.removeEventListener('dragenter', onDragEnter);
el.removeEventListener('dragover', onDragOver);