Closed Bug 1562794 Opened 6 years ago Closed 6 years ago

wish: middle-click paste should trigger implicit onkeyup()

Categories

(Core :: DOM: UI Events & Focus Handling, defect)

67 Branch
Desktop
Linux
defect
Not set
normal

Tracking

()

RESOLVED INVALID
Tracking Status
firefox67 --- affected
firefox68 --- affected
firefox69 --- affected

People

(Reporter: rn214, Unassigned)

Details

User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:67.0) Gecko/20100101 Firefox/67.0

Steps to reproduce:

Paste text into an <input>, using Linux's Middle-click paste, (rather than Ctrl-V).

This is a problem for forms, where the <input> uses onkeyup() to trigger validation and enable the next step of the process.

Actual results:

The new text was entered into the <input>, but the webpage didn't then respond to the characters by doing anything else.

The user-expectation of "paste" is "this should do exactly the same thing as typing a bunch of characters", but here, nothing happens.

To make the form work as intended, the user must know that they should then click in the <input>, and append space,backspace or similar.

Note that typing the characters, or pasting them with Ctrl-V does make the form work properly; this is only a problem for middle-mouse paste (which exists only on Linux).

Expected results:

A lot of forms do something like:
<input name="..." onkeyup="validateAndShowNext(this.value)">

  • This works when the user types text in manually.
  • It also works when the user Ctrl-V pastes, because of the keyup of Ctrl.
  • But it doesn't fire at all when middle-click pasting.

A complicating factor is that onpaste() doesn't help: onpaste() fires before the paste event actually happens, rather like onkeydown(). So even an aware developer cannot fix this.

So, my wish is this: for consistency with the principle of least-surprise, after the user does a middle-click paste, the browser should then implicitly fire the onkeyup event.

Thank you for your time and consideration.

Chromium also has the same behaviour; I filed this bug: https://bugs.chromium.org/p/chromium/issues/detail?id=980423

Hi Richard. I have attempted to reproduce your issue on Ubuntu 18.04.2 with Nightly v69.0a1 and Release v67.0.4 but pasting in any kind of input box using CTRL-V does nothing different than pasting using middle-mouse-click. Please try to reproduce your issue in safe-mode (here is a link that can help you: https://support.mozilla.org/en-US/kb/troubleshoot-firefox-issues-using-safe-mode)

If it still reproduces in safe-mode, then are there other prerequisites that I would need to favor before attempting to reproduce the issue?
Furthermore, please write EXACT steps to reproduce to avoid confusions.

Thank you for your contribution!

Flags: needinfo?(rn214)

Hi Daniel,

Thanks for your email. I confirm I can reproduce the problem in safe-mode, both on my own desktop, and in a brand new instance of firefox (the USB live-instance of ubuntu-budgie). To clarify, the problem is not that the "paste" doesn't work per se, it's that the events that the user/developer would expect to happen as a result of typing (or pasting) don't trigger. For example, validating that 2 passwords match, checking that a string is valid, or allowing the user to progress to the next part of the page. Anything that relies on onkeyup().

I think it might help if I give a simple example; here's a page I wrote for you to test with.
https://richardneill.org/tmp/mozpaste.html
For convenience, the code is below:

I hope this helps.

<html>
<head><title>Paste Test</title></head>
<body>
<h1>Paste Test</h1>

<p>This shows the way in which JS validation fails in the special case where text is middle-pasted.</p>
<ol>
<li>Try typing text into the input below. Note that, on every keystroke, JS copies it, and calculates/updates the length.
<li>Now, try copy-pasting, using Ctrl-C,Crtl-V. Note that the length and copy are as you'd expect.
<li>Now, try pasting using middle-click paste (this is a Linux-only feature). Note that the JS does NOT trigger.
</ol>

<p>Text goes here: <input id='theinput' onkeyup="validate(this)" placeholder="type or paste here"></p>
<p>Length of text = <b id='result'>...</b></p>
<p>Copy of text = <i id='copy'>....</i></p>

<script>
function validate(theInput){
var result = document.getElementById('result');
var copy = document.getElementById('copy');
copy.innerHTML = theInput.value;
var len = theInput.value.length;
result.innerHTML = len;
}
</script>
</body>
</html>

Flags: needinfo?(rn214)

I can confirm the reproduction that the reporter describes, both in Nightly v69.0a1, Beta v68.0, Release v67.0.4 and in Latest Chrome.
However, I do not know whether this issue is valid. I will set its component as (Core) User events and focus handling. If incorrect, please set a more appropriate component.

Status: UNCONFIRMED → NEW
Component: Untriaged → User events and focus handling
Ever confirmed: true
OS: Unspecified → Linux
Product: Firefox → Core
Hardware: Unspecified → Desktop

There's another corner-case I hadn't thought of (and which doesn't apply only to Linux): Right-click+choose paste.
There's also a better way for web authors to solve it: use oninput rather than onkeyup.

Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.