Skip to content
This repository was archived by the owner on Apr 16, 2026. It is now read-only.

Fix middle-click paste on Firefox. - #5751

Merged
marijnh merged 1 commit into
codemirror:masterfrom
nchevobbe:firefox-middle-click
Jan 22, 2019
Merged

marijnh merged 1 commit into
codemirror:masterfrom
nchevobbe:firefox-middle-click

Conversation

@nchevobbe

Copy link
Copy Markdown
Contributor

The current solution consists in focusing the
input when the scroll container capture a paste
event, which does not work on Firefox.

In order to fix this, creating a new paste event,
copying the clipboardData and dispatching it
on the textarea seems to do the trick.

This works on Firefox 64, with the
config set to true.

The current solution consists in focusing the
input when the scroll container capture a paste
event, which does not work on Firefox.

In order to fix this, creating a new paste event,
copying the clipboardData and dispatching it
on the textarea seems to do the trick.

This works on Firefox 64, with the
config set to true.
@nchevobbe

Copy link
Copy Markdown
Contributor Author

I'm only able to test this on OSX with Firefox (using the MiddleClick software to have a true middle-click). I did not find a way to enable middle-click paste on Chrone on OSX.

I would be interested to know if everything is okay in other browser and platforms.

@marijnh

marijnh commented Jan 18, 2019

Copy link
Copy Markdown
Member

Did you test whether this breaks middle-click paste on Chrome? There dispatchEvent will also be present, so if it works as-is on Chrome, it looks like the fallback code isn't going to be used anywhere.

@marijnh

marijnh commented Jan 18, 2019

Copy link
Copy Markdown
Member

Unfortunately, this works neither in Chrome nor on Firefox for me (using Linux)

@nchevobbe

Copy link
Copy Markdown
Contributor Author

Did you test whether this breaks middle-click paste on Chrome? There dispatchEvent will also be present, so if it works as-is on Chrome, it looks like the fallback code isn't going to be used anywhere.

Yeah, I was just being cautious for old-browser support.

@nchevobbe

Copy link
Copy Markdown
Contributor Author

Unfortunately, this works neither in Chrome nor on Firefox for me (using Linux)

:/ , I'm positive it should work on Firefox (maybe only Nightly for Linux, but I doubt it). Okay, time to boot-up my VM.

@marijnh

marijnh commented Jan 18, 2019

Copy link
Copy Markdown
Member

I'm testing with Firefox 64.0.2

@nchevobbe

nchevobbe commented Jan 21, 2019 •

Copy link
Copy Markdown
Contributor Author

Hello Martin,

I put up a page to test this PR : https://codemirror-firefox-middle-click.glitch.me/

It's working for me on:

  • Firefox 64+ on OSX
  • Firefox 67 on Ubuntu 17.10 (64-bit)
  • Chromium 67.0.3396.99 on Ubuntu 17.10 (64-bit)

I'm currently upgrading my Ubuntu VM in order to test Firefox 64 on it.

Could you tell me if:

  • it still does not work for you with my demo page
  • what steps you do to try to paste (I tested the patch by middle-clicking on the current cursor line, on the cursor itself, and also on part of the screen which is only covered by the scroll container, but maybe I'm missing something).

Thanks!

@nchevobbe

Copy link
Copy Markdown
Contributor Author

Verified it also works on:

  • Chromium 71.0.3578.98, Ubuntu 18.04 (64-bit)
  • Firefox 64, Ubuntu 18.04 (64-bit)

@marijnh

marijnh commented Jan 21, 2019

Copy link
Copy Markdown
Member

I can't see the page you put up (there's no link), but retrying the patch, I can see Firefox work now. Chrome (71.0.3578.98) still doesn't do anything when I middle click on an editor.

@nchevobbe

Copy link
Copy Markdown
Contributor Author

@marijnh

marijnh commented Jan 21, 2019

Copy link
Copy Markdown
Member

Same problem. Though I did notice that middle-click paste on Chrome works when the editor is unfocused, but not when it has focus.

@nchevobbe

Copy link
Copy Markdown
Contributor Author

Chrome (71.0.3578.98) still doesn't do anything when I middle click on an editor.

worst case, I could use the gecko floag from https://github.com/codemirror/CodeMirror/blob/ed8dfeb5e2ed25b5dd1f1eccc7b757ca6dbd118d/src/util/browser.js#L6, but i'd like not to.

Though I did notice that middle-click paste on Chrome works when the editor is unfocused, but not when it has focus.

That's a lead, I'll check this.

@nchevobbe

nchevobbe commented Jan 21, 2019 •

Copy link
Copy Markdown
Contributor Author

One silly question: does it works for you on Chrome without this patch? (it does on my machine on https://codemirror.net/demo/simplemode.html)

@marijnh

marijnh commented Jan 21, 2019

Copy link
Copy Markdown
Member

Not a silly question at all, it seems! It doesn't, and in fact old versions also no longer work, so I guess something in Chrome changed that broke the existing kludge. Interesting that no one seems to have complained about it yet.

Given that, I guess it'd be a good idea to drop the focus kludge code entirely, since it won't be firing or working anywhere.

@nchevobbe

Copy link
Copy Markdown
Contributor Author

Could this be somehow OS specific? What distrib+version are you testing on? (As stated before, it does work for me on Chromium, on Ubuntu, both with and without my patch)

@marijnh

marijnh commented Jan 21, 2019

Copy link
Copy Markdown
Member

Maybe. I'm using Debian 9.6. Are you able to test with Google's Chrome packages?

@nchevobbe

Copy link
Copy Markdown
Contributor Author

It's working for me, both with and without my patch on Google Chrome 71.0.3578.98 (Official Build) (64-bit)

I'm going to grab a Debian image and check everything there.

@marijnh

marijnh commented Jan 21, 2019

Copy link
Copy Markdown
Member

I guess it's more likely to be a strange local issue, at this point. I'm spinning up another Debian machine to see if it's better there.

@marijnh

marijnh commented Jan 21, 2019

Copy link
Copy Markdown
Member

Hm, nope, same problem in Chrome 69 there.

@marijnh

marijnh commented Jan 21, 2019

Copy link
Copy Markdown
Member

(And by 'same issue' I mean that it doesn't work at all before your patch, and only works when unfocused with the patch, so the patch still is an improvement.)

@nchevobbe

Copy link
Copy Markdown
Contributor Author

Okay, so on Debian it's working for Firefox, and for Chromium, but only if unfocused (same as you basically). I can see the textarea focus event listener being fired, but I don't know if it may cause the issue.
Should we proceed with this patch and create an issue for Debian+Chrome ?

@marijnh
marijnh merged commit 2dab4d5 into codemirror:master Jan 22, 2019
@marijnh

marijnh commented Jan 22, 2019

Copy link
Copy Markdown
Member

Yes, I think that's reasonable. Thanks for figuring out this workaround for Firefox!

@nchevobbe

Copy link
Copy Markdown
Contributor Author

Thanks for helping me figuring this out @marijnh :)
Also, thanks for maintaining this repo (and for the new version, I'm excited to try this one out :) )

@dmitry-at-publons

Copy link
Copy Markdown

I've just tried https://codemirror-firefox-middle-click.glitch.me/:

Firefox 64.0 at Ubuntu 18.04: pasting works, but copying text from a form (selecting with a mouse or double-clicking) does not.

Chromium 71 at Ubuntu 18.04: everything works

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants