Check for touch-action styles before dragging#1890
Conversation
🦋 Changeset detectedLatest commit: 8e3f05e The changes in this PR will be included in the next version bump. This PR includes changesets to release 9 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@dnd-kit/abstract
@dnd-kit/collision
@dnd-kit/dom
@dnd-kit/geometry
@dnd-kit/helpers
@dnd-kit/react
@dnd-kit/solid
@dnd-kit/state
@dnd-kit/svelte
@dnd-kit/vue
commit: |
clauderic
left a comment
There was a problem hiding this comment.
Summary
This PR adds a check in PointerSensor.preventActivation that prevents touch-based drag from starting if the activator element doesn't have touch-action: none set. The intent is to avoid attempting drags that the browser would cancel due to scroll/gesture handling.
Feedback
Suggestions
PointerSensor.ts:76-83— This change silently disables touch dragging for any user who hasn't explicitly settouch-action: noneon their draggable elements. Existing users who currently have touch dragging working (perhaps relying on the browser tolerating the conflict) will find touch dragging silently broken after upgrading. This may be more impactful than a patch warrants, and could benefit from documentation (e.g., a note in the migration guide or in the JSDoc forpreventActivation) explaining the requirement.- Consider whether the check should look at the element under the pointer (
event.target) in addition to or instead of the activator, since a parent element withtouch-action: autocan still intercept touch events even if the draggable hastouch-action: none. - Minor: the trailing whitespace removal in
activationConstraintsis a nice cleanup but slightly noisy in the diff.
Changeset
- Status: present, bump type patch for
@dnd-kit/dom— correct for this kind of behavioral fix.
Overall
The underlying motivation is solid — trying to drag without touch-action: none leads to unreliable behavior on mobile, and detecting this upfront is cleaner than a silent failure. The potential for silent regressions in existing setups is worth flagging for @clauderic to consider before merging. Thanks for contributing this, @rjur11!
[claude-review]
Adds touch-action CSS detection to PointerSensor's default
preventActivationfunction. Only allows touch-based dragging whentouch-action: noneis set, preventing activation attempts that the browser would cancel for scroll/gesture handling.