Page MenuHomePhabricator

OO.ui.TextInputWidget's maxLength option limits by UTF-16 code units, not characters as documented
Closed, ResolvedPublic


The maxLength configuration option to OO.ui.TextInputWidget is documented as "Maximum number of characters allowed in the input." However, what it actually does is set the maxLength attribute on the HTML <input> element, which according to HTML5 specifies the maximum length in "code units".

This makes a difference if someone is entering characters from outside the Unicode Basic Multilingual Plane, as in UTF-16 these characters consist of two code units.

I'll leave it to you to decide whether the better fix is to stop using the HTML5 maxLength attribute in favor of manual validation or to simply update the documentation to reference code units rather than characters.

Event Timeline

matmarex subscribed.

I'm going to update the docs.

Change 408312 had a related patch set uploaded (by Bartosz Dziewoński; owner: Bartosz Dziewoński):
[oojs/ui@master] TextInputWidget: Document that 'maxLength' counts UTF-16 code units

Change 408312 merged by jenkins-bot:
[oojs/ui@master] TextInputWidget: Document that 'maxLength' counts UTF-16 code units

Volker_E edited projects, added OOUI (OOUI-0.25.2); removed OOUI.