Page MenuHomePhabricator

jquery.byteLimit doesn't work when the content is pasted using the mouse
Closed, ResolvedPublic8 Estimated 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:

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).

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 is this still a problem ? Cause this thing listens to almost every event in the book...

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

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

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