From 4dffbfe6fafd55e6a5b75629386a7283a2ece360 Mon Sep 17 00:00:00 2001 From: Dave Richer Date: Mon, 23 Sep 2024 19:26:40 -0400 Subject: [PATCH] IO-2931-Visual-Production-Board-Drag-and-Drop-on-Touch-Devices - Add additional fixes / optimizations, from parent repo Signed-off-by: Dave Richer --- .../trello-board/dnd/lib/state/get-droppable-over.js | 4 ++-- .../use-droppable-publisher/get-closest-scrollable.js | 3 ++- .../dnd/lib/view/use-style-marshal/get-styles.js | 8 +++++++- .../dnd/lib/view/use-style-marshal/use-style-marshal.js | 4 +++- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/client/src/components/production-board-kanban/trello-board/dnd/lib/state/get-droppable-over.js b/client/src/components/production-board-kanban/trello-board/dnd/lib/state/get-droppable-over.js index dcf0cf04c..cb7f7c75b 100644 --- a/client/src/components/production-board-kanban/trello-board/dnd/lib/state/get-droppable-over.js +++ b/client/src/components/production-board-kanban/trello-board/dnd/lib/state/get-droppable-over.js @@ -25,8 +25,8 @@ function getFurthestAway({ pageBorderBox, draggable, candidates }) { const axis = candidate.axis; const target = patch( candidate.axis.line, - // use the current center of the dragging item on the main axis - pageBorderBox.center[axis.line], + // use the center of the list on the main axis + candidate.page.borderBox.center[axis.line], // use the center of the list on the cross axis candidate.page.borderBox.center[axis.crossAxisLine] ); diff --git a/client/src/components/production-board-kanban/trello-board/dnd/lib/view/use-droppable-publisher/get-closest-scrollable.js b/client/src/components/production-board-kanban/trello-board/dnd/lib/view/use-droppable-publisher/get-closest-scrollable.js index 923622788..0b069cce5 100644 --- a/client/src/components/production-board-kanban/trello-board/dnd/lib/view/use-droppable-publisher/get-closest-scrollable.js +++ b/client/src/components/production-board-kanban/trello-board/dnd/lib/view/use-droppable-publisher/get-closest-scrollable.js @@ -5,6 +5,7 @@ import getBodyElement from "../get-body-element"; const isEqual = (base) => (value) => base === value; const isScroll = isEqual("scroll"); const isAuto = isEqual("auto"); +const isOverlay = isEqual("overlay"); const isVisible = isEqual("visible"); const isEither = (overflow, fn) => fn(overflow.overflowX) || fn(overflow.overflowY); const isBoth = (overflow, fn) => fn(overflow.overflowX) && fn(overflow.overflowY); @@ -14,7 +15,7 @@ const isElementScrollable = (el) => { overflowX: style.overflowX, overflowY: style.overflowY }; - return isEither(overflow, isScroll) || isEither(overflow, isAuto); + return isEither(overflow, isScroll) || isEither(overflow, isAuto) || isEither(overflow, isOverlay); }; // Special case for a body element diff --git a/client/src/components/production-board-kanban/trello-board/dnd/lib/view/use-style-marshal/get-styles.js b/client/src/components/production-board-kanban/trello-board/dnd/lib/view/use-style-marshal/get-styles.js index 418acb50b..f62947525 100644 --- a/client/src/components/production-board-kanban/trello-board/dnd/lib/view/use-style-marshal/get-styles.js +++ b/client/src/components/production-board-kanban/trello-board/dnd/lib/view/use-style-marshal/get-styles.js @@ -83,7 +83,13 @@ const getFinalStyles = (contextId) => { return { selector: getSelector(attributes.draggable.contextId), styles: { - dragging: transition, + dragging: ` + ${transition} + user-select: none; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + `, dropAnimating: transition, userCancel: transition } diff --git a/client/src/components/production-board-kanban/trello-board/dnd/lib/view/use-style-marshal/use-style-marshal.js b/client/src/components/production-board-kanban/trello-board/dnd/lib/view/use-style-marshal/use-style-marshal.js index 19457b312..b27b4d534 100644 --- a/client/src/components/production-board-kanban/trello-board/dnd/lib/view/use-style-marshal/use-style-marshal.js +++ b/client/src/components/production-board-kanban/trello-board/dnd/lib/view/use-style-marshal/use-style-marshal.js @@ -67,7 +67,9 @@ export default function useStyleMarshal(contextId, nonce) { const remove = (ref) => { const current = ref.current; invariant(current, "Cannot unmount ref as it is not set"); - getHead().removeChild(current); + if (getHead().contains(current)) { + getHead().removeChild(current); + } ref.current = null; }; remove(alwaysRef);