clauderic / dnd-kit

The modern, lightweight, performant, accessible and extensible drag & drop toolkit for React.
http://dndkit.com
MIT License
12.89k stars 640 forks source link

Mystery "Draggable" text element in DOM #382

Closed n8sabes closed 2 years ago

n8sabes commented 3 years ago

On iOS, I am seeing an invisible text field become selected in the top-left of the page on a long-press. I have searched my code but nothing is standing out.

QUESTION: Does dnd-kit inject a "Draggable" text element into the DOM when dragging starts? If so, is there a way to obscure or prevent this element from being auto-selected?

Mystery Text

clauderic commented 3 years ago

Could be the LiveRegion component which renders accessibility announcements 🤔 https://github.com/clauderic/dnd-kit/blob/master/packages/accessibility/src/components/LiveRegion/LiveRegion.tsx

I think it needs userSelect: 'none' style, feel free to open a PR, otherwise I should get to this in the next few weeks.

n8sabes commented 3 years ago

Hi @clauderic,

I tried adding userSelect: 'none', including !important everywhere I could think of (from handlers to DOM elements), but still get the 'Draggable' text injected and selection of the text.

Thank you for including a fix for this.

clauderic commented 3 years ago

You may need to try WebkitUserSelect: 'none'

n8sabes commented 3 years ago

Good thought. I just tried explicit inclusion of the webkit vendor prefix, but unfortunately get the same result.

MKraust commented 11 months ago

Same problem using these packages. I have tried to add user-select: none, -webkit-user-select: none everywhere, but unfortunately with no results :(

"@dnd-kit/core": "^6.1.0",
"@dnd-kit/sortable": "^8.0.0",
"@dnd-kit/utilities": "^3.2.2",

UPD: solved with these styles on <DragLayer className={cn.dragLayer} />:

.dragLayer, .dragLayer * {
  user-select: none;
  -webkit-user-select: none:
}