https://bugzilla.wikimedia.org/show_bug.cgi?id=29467

--- Comment #11 from Krinkle <[email protected]> 2012-08-16 16:43:14 UTC ---
(In reply to comment #10)
> >On that event check the byteLength after the insertion and if too long, chop
> >down to the limit.
> 
> Say you have 240 bytes in the text box. You realize you forgot to write
> something at the beginning of your edit summary. You move your cursor to the
> begining of the input box and type 30 more bytes of characters. Now the byte
> limiter has chopped off the last 15 bytes of your summary with no indication 
> to
> you (since the last 15 bytes are at end of textbox and not visible). I think
> this would be very confusing to the user.

Fair point but unless you have a better idea, that is still much better than
the current way:

Enter < limit bytes of text in the box. Use any method of text insertion other
than *plain* typing that will  (pasting, dragging, selecting text than typing
or pasting etc.) and that method of insertion will be prevented from happening
with no indication whatsoever.

Also by listening on character insertion it is unable to limit insertion
through those other methods. And no, it is not feasible to try and account for
all those methods because there are too many:
* typing
* selecting a word and typing more (e.g. "foo bar baz", limit 11, select "baz"
type "x". this has to be impossible, but is not possible if limit is 11 and
method is naive and checks length + to-be-inserted character)
* using any non-plain input (e.g. spell check correction, pasting, dragging,
type suggestions on mobile devices, and custom javascript input methods for
foreign characters that consider typing several characters as one (e.g. "" ->
"a" -> "ae" -> "รค"). In the latter case we need to not prevent the insertion.

The best way I can see on short term is instead of listening on input, listen
for changes and when they happen let the whole call stack / event loop run to
completion and then chop off to the limit if needed (e.g. a 0ms setTimeout,
just to put it at end of the loop to allow dom events to run, since those are
synchronous).

-- 
Configure bugmail: https://bugzilla.wikimedia.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
You are on the CC list for the bug.
_______________________________________________
Wikibugs-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l

Reply via email to