diff options
author | Jacob Schatz <jschatz@gitlab.com> | 2016-08-03 04:15:39 +0000 |
---|---|---|
committer | Jacob Schatz <jschatz@gitlab.com> | 2016-08-03 04:15:39 +0000 |
commit | 195b20e1b9ff08437c5a436dc14f04e7f1bee807 (patch) | |
tree | c72759b1b88720c7d3f54fcad14a5b76793fa519 | |
parent | 3552900733aa86035d8cc50a1180727cba5915bb (diff) | |
parent | 6e87ce282db9f5264f77ae2238c1fff23beece1a (diff) | |
download | gitlab-ce-195b20e1b9ff08437c5a436dc14f04e7f1bee807.tar.gz |
Merge branch 'discussion-reply-button-performance' into 'master'
Remove delay when hitting Reply... button on page with a lot of comments
Every time the "Reply..." button was hit, a new `GLForm` was instantiated (which is fine), which would then call `GitLab.GfmAutoComplete.setup()` without specifying which textarea we needed autocompletion on, which resulted in `GitLab.GfmAutoComplete.setup` iterating through every single textarea on the page. On a page with a lot of comments, where each comment would have its own textarea that will be used to edit the comment, this would take a long time and cause the whole page to hang for 2 seconds when a "Reply..." button was clicked.
See merge request !5602
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | app/assets/javascripts/gfm_auto_complete.js | 4 | ||||
-rw-r--r-- | app/assets/javascripts/gl_form.js | 2 |
3 files changed, 4 insertions, 3 deletions
diff --git a/CHANGELOG b/CHANGELOG index b936d91aa14..db2617dcbd7 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -19,6 +19,7 @@ v 8.11.0 (unreleased) - Clean up unused routes (Josef Strzibny) - Add green outline to New Branch button. !5447 (winniehell) - Update to gitlab_git 10.4.1 and take advantage of preserved Ref objects + - Remove delay when hitting "Reply..." button on page with a lot of discussions - Retrieve rendered HTML from cache in one request - Fix renaming repository when name contains invalid chararacters under project settings - Optimize checking if a user has read access to a list of issues !5370 diff --git a/app/assets/javascripts/gfm_auto_complete.js b/app/assets/javascripts/gfm_auto_complete.js index 41f4c1914f2..2e5b15f4b77 100644 --- a/app/assets/javascripts/gfm_auto_complete.js +++ b/app/assets/javascripts/gfm_auto_complete.js @@ -47,8 +47,8 @@ } } }, - setup: function(wrap) { - this.input = $('.js-gfm-input'); + setup: function(input) { + this.input = input || $('.js-gfm-input'); this.destroyAtWho(); this.setupAtWho(); if (this.dataSource) { diff --git a/app/assets/javascripts/gl_form.js b/app/assets/javascripts/gl_form.js index 6ac7564a848..528a673eb15 100644 --- a/app/assets/javascripts/gl_form.js +++ b/app/assets/javascripts/gl_form.js @@ -21,7 +21,7 @@ this.form.find('.div-dropzone').remove(); this.form.addClass('gfm-form'); disableButtonIfEmptyField(this.form.find('.js-note-text'), this.form.find('.js-comment-button')); - GitLab.GfmAutoComplete.setup(); + GitLab.GfmAutoComplete.setup(this.form.find('.js-gfm-input')); new DropzoneInput(this.form); autosize(this.textarea); this.addEventListeners(); |