diff --git a/styles/dnd.module.css b/styles/dnd.module.css index 3b51ef8d..2fd2244a 100644 --- a/styles/dnd.module.css +++ b/styles/dnd.module.css @@ -18,7 +18,7 @@ @media (max-width: 768px) { .draggable { /* https://developer.mozilla.org/en-US/docs/Web/CSS/touch-action */ - touch-action: none; + touch-action: pan-y; user-select: none; -webkit-user-select: none; -moz-user-select: none; diff --git a/wallets/client/context/dnd.js b/wallets/client/context/dnd.js index 198810ed..5c735383 100644 --- a/wallets/client/context/dnd.js +++ b/wallets/client/context/dnd.js @@ -123,14 +123,18 @@ export function useDndHandlers (index) { if (isTouchDragging) { // Find the element under the touch point const elementUnderTouch = document.elementFromPoint(touch.clientX, touch.clientY) - if (elementUnderTouch) { - const element = elementUnderTouch.closest('[data-index]') - if (element) { - const elementIndex = parseInt(element.dataset.index) - if (elementIndex !== index) { - dispatch({ type: DRAG_ENTER, index: elementIndex }) - } - } + if (!elementUnderTouch) { + return dispatch({ type: DRAG_LEAVE }) + } + + const element = elementUnderTouch.closest('[data-index]') + if (!element) { + return dispatch({ type: DRAG_LEAVE }) + } + + const elementIndex = parseInt(element.dataset.index) + if (elementIndex !== index) { + dispatch({ type: DRAG_ENTER, index: elementIndex }) } } }