yabwe / medium-editor

Medium.com WYSIWYG editor clone. Uses contenteditable API to implement a rich text solution.
https://yabwe.github.io/medium-editor/
Other
16.04k stars 1.86k forks source link

Keyboard focus is lost after pasting text (Firefox) #1166

Open dcsaszar opened 8 years ago

dcsaszar commented 8 years ago

Description

The editable area loses the (visible) input cursor after pasting text in Firefox. Chrome is fine.

Steps to reproduce

  1. Use FF (47.0.1)
  2. visit https://yabwe.github.io/medium-editor/
  3. click the editable text
  4. paste something (using ctrl+v)

Expected behavior: [What you expected to happen]

Actual behavior: [What actually happened]

biggieman commented 8 years ago

+1

nmielnik commented 8 years ago

This could definitely be related to #1178 , so if anyone investigates fixing either issue please try to investigate both at the same time.

dcsaszar commented 8 years ago

5087f4b84206aa7c76fe91204bff26f094dc1cb9 is the last working commit after that the dist is broken for a while (7 commits in the history of https://github.com/yabwe/medium-editor/commits/master/src/js/extensions/paste.js) 3cc4165da287a4987a1e4807f4d24581dcffc698 has a working dist and shows the issue

One of the causes appears to be setting the .focus() to the pasteBin. If I comment out this line, it works.

dcsaszar commented 8 years ago

I don't know why we need the focus() on the paste bin. So, currently I see two possible solutions:

j0k3r commented 8 years ago

Focus is needed so the content you just pasted is written into the paste bin. Otherwise the whole pastebin shouldn't work. I think we should better put the focus back to the editable element when pasting is done.

dcsaszar commented 8 years ago

How would I know the pastebin isn't working? I tried deleting the focus stuff and successfully pasted in the default index.html in Firefox and Chrome.

j0k3r commented 8 years ago

Well, if what you pasted was actually pasted, it means the whole paste stuff is working. Which looks strange without the focus :neutral_face:

dcsaszar commented 8 years ago

I'll open a PR and you can have a look.