Page MenuHomePhabricator

TextInputWidget auto-resize method is a little inefficient
Closed, ResolvedPublic

Description

Quoth Roan, OOJS-UI creates and measures a clone of the textarea on every keyup event. That's just silly.

I don't know what the best solution is, here, but maybe start by debouncing the events, then maybe move on to a better measuring/dimension-guessing method.


Version: unspecified
Severity: enhancement

Event Timeline

bzimport raised the priority of this task from to Low.Nov 22 2014, 3:52 AM
bzimport set Reference to bz73328.

(In reply to Mark Holmquist from comment #0)

Quoth Roan, OOJS-UI creates and measures a clone of the textarea on every
keyup event. That's just silly.

I don't know what the best solution is, here, but maybe start by debouncing
the events, then maybe move on to a better measuring/dimension-guessing
method.

I very vaguely recall this being something to do with browser compatibility, but maybe it's all an hallucination.

Indeed on some level it is - I used this method to fix UW's auto-resize ability. But I think there are avenues to making it faster that don't require losing compatibility.

Change 176475 had a related patch set uploaded (by Prtksxna):
TextInputWidget: Stop adjustSize if the value of the textarea is the same

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

Patch-For-Review

Change 176476 had a related patch set uploaded (by Prtksxna):
TextInputWidget: Reuse a single clone instead of appending and removing new ones

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

Patch-For-Review

Change 176475 merged by jenkins-bot:
TextInputWidget: Stop adjustSize if the value of the textarea is the same

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

Jdforrester-WMF renamed this task from OOjs UI: TextInputWidget auto-resize method is a little inefficient to TextInputWidget auto-resize method is a little inefficient.Nov 29 2014, 7:44 PM
Jdforrester-WMF closed this task as Resolved.
Jdforrester-WMF assigned this task to Prtksxna.
Jdforrester-WMF set Security to None.

We're now better filtering out when the textarea hasn't changed. We can't do real debouncing because that causes really horrible UX (scrollbars flickering on and off).

Switching from cloning the input every time to cloning it once and reusing gives a pretty small performance improvement, but it's there. http://jsperf.com/adjustsize/2 Not sure if it's worth changing, given the possible unverified wild-guessing issues discussed on the patch.

I have updated the patch to use .style.display. Testing is welcome.

Change 176476 merged by jenkins-bot:
TextInputWidget: Reuse a single clone instead of appending and removing new ones

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