onaluf / fate

Flexible Angular Text Editor
MIT License
37 stars 14 forks source link

Text selection issue when mouse leaves component #59

Closed Void-0 closed 5 years ago

Void-0 commented 5 years ago

I've come across a small bug related to text selection (with the mouse).

How to reproduce bug:

  1. go to onaluf.github.io/fate/
  2. focus any of the inputs (anywhere inside text is fine) and select some text (only one word for example).
  3. remove focus (click anywhere outside)
  4. try directly selecting some text (or all of it) with the mouse (while input is not focused) while dragging and release the mouse button outside of the component. (bug only appears if the mouse was released outside)
  5. Try clicking any of the buttons inside the menu like bold
  6. The previously selected word at step one is getting the bold applied and not the text selected at step 4.

Basically the component just ignores the new selection if it ends outside the component and uses the previously saved selection instead. This can be quite annoying if you want to for example quickly select all the text inside the text field and just slide your mouse out of the edge of the component.

Funny thing is though, if you don't focus the input at least once after loading the page (and there is no saved previous selection) then the new selection, even if the mouse ends up outside the component is recognised (and the bug is not produced). My guess is this has something to do with how the last selection is saved by the component and somehow the saved position takes priority over the new one if the mouse leaves the component while selecting text.

onaluf commented 5 years ago

Yeah there is lot's of fishy things going on with selections to make it work on all browser... I'll have a look but I think I know what's going on.

onaluf commented 5 years ago

:tada: This issue has been resolved in version 1.9.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket: