React-dnd: Can't select input or texarea content

Created on 21 Jan 2016  路  2Comments  路  Source: react-dnd/react-dnd

From #178:

'Attempt to select input or textarea content with touchpad/mouse starts dragging parent element.'

This works in Safari 9.0.2 but does not work in Chrome 47.0

Most helpful comment

It seems to work for textarea but not for input. I added an <input type="text" /> to the Sortable/Simple example:

reactdnd

All 2 comments

I can鈥檛 reproduce this with Chrome 47. I tested OS X and Windows.
Here鈥檚 what I see:

feb 14 2016 00 25

Selecting text works fine. Note that _if you drag by the corner where there is no text yet_, indeed the textarea is draggable. This is just how browser works; we can鈥檛 prevent it without introducing fragile checks that would break with other edge cases.

If you鈥檇 like to disable this, your best bet is to keep some kind of isEditing state in the parent component, pass isEditing, onFocus and onBlur to your drag source, and define canDrag(monitor, props) to return !props.isEditing so that you explicitly forbid dragging while the input if focused.

It seems to work for textarea but not for input. I added an <input type="text" /> to the Sortable/Simple example:

reactdnd

Was this page helpful?
0 / 5 - 0 ratings