Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Friend <nathan@gitlab.com>2019-05-17 20:05:15 +0300
committerNathan Friend <nathan@gitlab.com>2019-05-17 20:05:15 +0300
commit2a4a732db94652a131aae0fc57801a8f09fabead (patch)
treeb8a201b60826683c8d262d590e2a79d2b7d8cc26 /app/assets/javascripts/dirty_submit
parent913bc9649b012b178ef1acb9ef254fcc565be248 (diff)
Fix throttling issue in form dirty checking
This commit fixes an issue that was causing the "Save changes" button to be incorrectly enabled or disabled when changes were made to a form. (Specifically, some of the subsections in the project settings pages.)
Diffstat (limited to 'app/assets/javascripts/dirty_submit')
-rw-r--r--app/assets/javascripts/dirty_submit/dirty_submit_form.js11
1 files changed, 8 insertions, 3 deletions
diff --git a/app/assets/javascripts/dirty_submit/dirty_submit_form.js b/app/assets/javascripts/dirty_submit/dirty_submit_form.js
index 765969daa32..0fcaec9531c 100644
--- a/app/assets/javascripts/dirty_submit/dirty_submit_form.js
+++ b/app/assets/javascripts/dirty_submit/dirty_submit_form.js
@@ -21,10 +21,15 @@ class DirtySubmitForm {
}
registerListeners() {
- const throttledUpdateDirtyInput = _.throttle(
- event => this.updateDirtyInput(event),
- DirtySubmitForm.THROTTLE_DURATION,
+ const getThrottledHandlerForInput = _.memoize(() =>
+ _.throttle(event => this.updateDirtyInput(event), DirtySubmitForm.THROTTLE_DURATION),
);
+
+ const throttledUpdateDirtyInput = event => {
+ const throttledHandler = getThrottledHandlerForInput(event.target.name);
+ throttledHandler(event);
+ };
+
this.form.addEventListener('input', throttledUpdateDirtyInput);
this.form.addEventListener('change', throttledUpdateDirtyInput);
$(this.form).on('change.select2', throttledUpdateDirtyInput);