Page MenuHomePhabricator

jquery.byteLimit doesn't work when the content is pasted using the mouse
Closed, ResolvedPublic8 Estimate Story Points

Description

Screencast showing the bug

If I use the mouse to paste a string which exceeds the edit summary limit, it is not truncated until I click in the summary again, or press some key.


Version: 1.23.0
Severity: normal

Attached:

Details

Reference
bz62319
Related Gerrit Patches:

Event Timeline

bzimport raised the priority of this task from to Low.Nov 22 2014, 3:04 AM
bzimport set Reference to bz62319.
bzimport added a subscriber: Unknown Object (MLST).
He7d3r created this task.Mar 6 2014, 12:52 PM

What browser are you using? The byteLimit plugin is listening for cut/paste events which modern browsers should (do?) fire when pasting content in the manner described.

In addition to keyboard events (of course), it also listens to click events, focus/blur events and the generic change event.

I tested this on Google Chrome 33.0.1750.152 and Firefox 28.0.

He7d3r awarded a token.Jan 3 2015, 2:15 PM
TheDJ added a subscriber: TheDJ.Dec 21 2015, 4:21 PM

@He7d3r is this still a problem ? Cause this thing listens to almost every event in the book...

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptDec 21 2015, 4:21 PM

Yep. I was able to reproduce the same behavior shown in the screencast above (using Firefox 43 and Google Chrome 47) at https://test.wikipedia.org/wiki/TEST/T64319

TheDJ added a comment.Dec 21 2015, 9:05 PM

I can confirm now. It's rather tricky though... Especially on my mac...

matmarex claimed this task.Apr 16 2018, 6:13 PM
matmarex added a subscriber: Catrope.

That's amazing. What makes it even better is that while the input listens to key events, it doesn't appear to listen to the paste event, so if you paste using the right-click context menu, the truncation doesn't happen until you type into the input or blur it.

We definitely handle the 'paste' event. I just tried debugging this and it seems that the input's value is not updated until the event handler returns. I don't know if that is the expected behavior, but this deserves a new task.

Change 426966 had a related patch set uploaded (by Bartosz Dziewoński; owner: Bartosz Dziewoński):
[mediawiki/core@master] jquery.lengthLimit: Improve event handling

https://gerrit.wikimedia.org/r/426966

Change 426966 merged by jenkins-bot:
[mediawiki/core@master] jquery.lengthLimit: Fix 'cut'/'paste' event handling

https://gerrit.wikimedia.org/r/426966

TheDJ awarded a token.May 30 2018, 9:42 PM
matmarex closed this task as Resolved.May 30 2018, 10:21 PM
matmarex removed a project: Patch-For-Review.
Jdforrester-WMF set the point value for this task to 8.Jun 13 2018, 6:26 PM