layerssss / paste.js

read image/text data from clipboard (cross-browser)
http://layerssss.github.io/paste.js/
MIT License
463 stars 94 forks source link

Post-paste focus broken in Firefox v50+ #29

Closed pkaminski closed 8 years ago

pkaminski commented 8 years ago

In Firefox v50+ the focus doesn't return to the textarea after text is pasted. From a comment by @mystor in reviewable/reviewable#360:

This bug appears to have been caused by Firefox implementing the DataTransferItemList specification. I believe that this error is on your side, due to user-agent sniffing.

From my testing, you can reproduce this error in chromium by spoofing the Firefox user agent, and can avoid the problem in Firefox nightly by spoofing the chrome user agent.

It seems like in the "paste" listener you sniff the user agent, and use that to decide what action to perform. If the Firefox user agent is detected, you then check for the presence of e.clipboardData.items. In versions of Firefox less than 50, e.clipboardData.items will not be present, but in Firefox 50, we now implement this interface. This is probably what is breaking in your code.

layerssss commented 8 years ago

😆that's a great news coming from Firefox! I'll make adjustment and a new release before this weekend.

layerssss commented 8 years ago

@pkaminski Sorry I'll hold this a little bit until next week. Luckily it seems not so urgent because v50 hasn't been on any release channels yet, here are the versions (from https://www.mozilla.org/en-US/firefox/channel/):

pkaminski commented 8 years ago

Yeah, looks like v50 is scheduled for release in November, so no big rush. On the other hand, Reviewable has a disproportionately large audience of early-adopter developers, so v50 will become prevalent in this population much earlier.

pkaminski commented 8 years ago

Ping -- it's been a month, I think it would be good to get this fixed now since FF50 is moving into beta in 3 weeks.

layerssss commented 8 years ago

@pkaminski Get it, yeah, need to fix it now! 😆

pkaminski commented 8 years ago

Ping...

layerssss commented 8 years ago

✨ This issue is fixed! (and elegantly! )

Sorry for been super slow for those issues during the previous couple of months. I moved from China to New Zealand half a year ago. And most of the time just been travelling. I started working only a month ago with a group of awesome people at @boost . But it's a lot of amazing things happening now.

A million thanks for been a user of paste.js and forwarding those issues to me all the time. And Reviewable looks pretty neat. Keep up the good work!

pkaminski commented 8 years ago

Thanks @layerssss! Both for the fix and for making this super useful library in the first place. Enjoy your new job -- I keep talking about moving to NZ one day, and perhaps I eventually will. :)