From 7f0a4637eab4db9a1589e299212de9c037f0165b Mon Sep 17 00:00:00 2001 From: Matt Driscoll Date: Wed, 14 Feb 2024 11:01:53 -0800 Subject: [PATCH 1/3] fix: set the target as the host element when target contains a shadowRoot. #2346 --- src/Sortable.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Sortable.js b/src/Sortable.js index 74045d4f4..e091810fb 100644 --- a/src/Sortable.js +++ b/src/Sortable.js @@ -755,6 +755,10 @@ Sortable.prototype = /** @lends Sortable.prototype */ { while (target && target.shadowRoot) { target = target.shadowRoot.elementFromPoint(touchEvt.clientX, touchEvt.clientY); + const host = target.getRootNode().host; + if (host) { + target = host; + } if (target === parent) break; parent = target; } From 1e9ad0d56a9a88d75cad4872eb0b5e87ec56ec44 Mon Sep 17 00:00:00 2001 From: Matt Driscoll Date: Mon, 18 Mar 2024 11:16:30 -0700 Subject: [PATCH 2/3] review fixes uses getParentOrHost utility and moves logic to appropriate place --- src/Sortable.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/Sortable.js b/src/Sortable.js index e091810fb..823d88b32 100644 --- a/src/Sortable.js +++ b/src/Sortable.js @@ -35,7 +35,8 @@ import { scrollBy, clone, expando, - getChildContainingRectFromElement + getChildContainingRectFromElement, + getParentOrHost, } from './utils.js'; @@ -755,10 +756,6 @@ Sortable.prototype = /** @lends Sortable.prototype */ { while (target && target.shadowRoot) { target = target.shadowRoot.elementFromPoint(touchEvt.clientX, touchEvt.clientY); - const host = target.getRootNode().host; - if (host) { - target = host; - } if (target === parent) break; parent = target; } @@ -785,7 +782,7 @@ Sortable.prototype = /** @lends Sortable.prototype */ { target = parent; // store last element } /* jshint boss:true */ - while (parent = parent.parentNode); + while (parent = getParentOrHost(parent)); } _unhideGhostForTarget(); From 9fab4b9230d0456601078b271cd9a0b7f0de7fac Mon Sep 17 00:00:00 2001 From: Matt Driscoll Date: Mon, 18 Mar 2024 11:18:04 -0700 Subject: [PATCH 3/3] remove trailing comma for consistency --- src/Sortable.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Sortable.js b/src/Sortable.js index 823d88b32..3c85a0e5c 100644 --- a/src/Sortable.js +++ b/src/Sortable.js @@ -36,7 +36,7 @@ import { clone, expando, getChildContainingRectFromElement, - getParentOrHost, + getParentOrHost } from './utils.js';