No possibility to select text inside <input> when parent is draggable

后端 未结 4 1524
野趣味
野趣味 2021-01-17 10:59

This one is IE specific (not anymore, apparently). We have very simple code:

Text

4条回答
  •  北荒
    北荒 (楼主)
    2021-01-17 11:37

    One possible workaround to this solution is to remove the draggable attribute from the parent element in situations where you expect the text to be highlighted.

    For instance in an application I'm working on, we show text in a span by default, then reveal an input when the user clicks on it to edit. At that point we remove the draggable attribute until the user is done editing, and then readd it.

    That particular flow may or may not work for you, but if you can anticipate when the user might highlight, you can minimize the effect of the undesirable browser behavior. At minimum you can toggle draggable on focus and blur so that the user can highlight with the mouse if he's already editing the text.

提交回复
热议问题