Page MenuHomePhabricator

Cursor jumps to the end of the summary field after pasting more text than is allowed
Open, LowPublic

Description

Copying and pasting strings into the summary field

  1. Go to

https://en.wikipedia.org/wiki/WP:Sandbox?action=edit

  1. Copy a long string (but not longer than the limit for an edit summary). E.g. the copyright text which is above the editbox.
  2. Paste the string in the summary field
  3. Copy another string which is long enough to guarantee that both strings together have more characters than the limit for a summary. E.g.:

[[Test]] [[Test]] [[Test]] [[Test]] [[Test]] [[Test]] [[Test]]

  1. Position the cursor in the beginning of the summary (in the video, I pressed TAB, since I was in the editbox)
  2. Paste the second string

At this point, you'll notice the cursor to disappear. For some reason it jumps to the end of the summary field instead of staying right after the pasted string.

This is very inconvenient, since in order to rephrase my summary into a shorter one, I now have to find where the first string starts in order to delete the pasted summary!


Version: 1.23.0
Severity: minor

Attached:

Details

Reference
bz61450

Event Timeline

bzimport raised the priority of this task from to Low.Nov 22 2014, 2:59 AM
bzimport set Reference to bz61450.
bzimport added a subscriber: Unknown Object (MLST).

I took a quick look at jquery.byteLimit.js which implements the byte-length input limiting... it seems the cursor being moved is a side effect of modifying the contents of the input field (the trimming).

Note the same thing happens if you *type* past the limit too and aren't at the end already -- by default if you happen to be typing all-ASCII-able text you may not notice because you're hitting the browser's character limit.

One could possibly jump through some hoops to get the cursor position and reset it, but I wonder if the whole thing's worth it...

It might be better to give a warning that you're out of characters and just show a red border or a warning text, and let it just crop on the backend.

(In reply to Brion Vibber from comment #1)

One could possibly jump through some hoops to get the cursor position and
reset it, but I wonder if the whole thing's worth it...

There aren't that many hoops to jump through, at leats if you're willing to ignore IE<=8. I say that we are willing and will submit a patch in a second. :)

Change 114959 had a related patch set uploaded by Bartosz Dziewoński:
jquery.byteLimit: Restore caret position after limiting

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

Change 114959 abandoned by Bartosz Dziewoński:
jquery.byteLimit: Restore caret position after limiting

Reason:
I don't remember how this code works anymore. Meh.

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