Medium-editor: Keyboard focus is lost after pasting text (Firefox)

Created on 3 Aug 2016  路  8Comments  路  Source: yabwe/medium-editor

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]

  • the input cursor blinks after the pasted text
  • keyboard text input is still possible

Actual behavior: [What actually happened]

  • no input cursor
  • typing is not possible
  • pasting again still pastes correctly

Versions

  • medium-editor: 5.21.0
  • browser: Firefox
  • OS: Ubuntu
browser-firefox paste problem

Most helpful comment

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

All 8 comments

+1

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

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.

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

  • don't focus the paste bin at all (https://github.com/yabwe/medium-editor/blob/master/src/js/extensions/paste.js#L315-L320)
  • put the paste bin div into the editable element instead of the body (https://github.com/yabwe/medium-editor/blob/master/src/js/extensions/paste.js#L313 => sth like this.getEditorElements()[0].appendChild(pasteBinElm);)

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.

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.

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

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jorgedavila25 picture jorgedavila25  路  6Comments

tyler-johnson picture tyler-johnson  路  5Comments

nicks picture nicks  路  3Comments

taiji202 picture taiji202  路  6Comments

DylanPiercey picture DylanPiercey  路  5Comments