Make autosize fields more performant and remove broken autosize handle
In addition to autosize.js, we used to depend on a third-party library (ba-resize
) to help manage the resizing of textarea elements. We added some extra event handling logic on top of autosizejs to help those libraries work together. This MR removes that extra logic, since we removed ba-resize
several months ago, and because the listeners pile some DOM-heavy logic on top of what autosize.js already does, which contributes to very poor performance while keying in input on moderately large issues/MRs.
Eventually, we need to find a way to remove autosize.js completely. But since we depend heavily on it, removing it will require quite a lot of refactoring. I think this is a good first step.
The only noticeable change here will be that the resize handle will no longer be visible on textarea elements. The resizer handle doesn't even work as it should now. As you can see here, when you start typing after resizing the window, the textarea reverts to the size autosize.js sets. So the resize handler serves virtually no purpose, and hasn't for several months:
There was general agreement in discussion on Slack that it's okay to remove, particularly since it's contributing to a performance problem. After all, the need for a resizer handle is what autosize.js aims to remove.
After this change, autosize still works as it should:
Related to https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/12532d and https://gitlab.com/gitlab-org/gitlab-ce/issues/34637
Merge request reports
Activity
@rspeicher Ready for a blast from the past? I had to do some digging to trace the history of autosize.js in GitLab. I now see you added it here and then added some additional configuration here as part of adding the
jquery.ba-resize
library. A while back we removed ba-resize, and now I'm wondering whether this additional config is even neccessary, since it creates some performance issues when MRs get bigger.When I remove it, everything still seems to work fine, but maybe you have some extra insight?
Actually, just saw your commit message:
First, the autosize library was being too controlling and removed the `resize` property from any elements to which it was attached, removing the drag handle. Second, we detect when the user manually resizes an autosize textarea, and then remove the autosize behavior from it and increase its max-height. This should allow for the best of both worlds.
That gives me a lot to work with. Here's to detailed commit messages!
Edited by username-removed-408230@brycepj Yeah, I'm not sure this behavior ever worked ideally. Good luck!
added frontend ~18308 labels
assigned to @brycepj
added 193 commits
-
10a39033...a704f9e5 - 192 commits from branch
master
- c69331cc - Remove unneeded autosize js config.
-
10a39033...a704f9e5 - 192 commits from branch
mentioned in issue #34476 (closed)
changed milestone to %9.4
@ClemMakesApps Can you review?
assigned to @ClemMakesApps