diff options
author | Sam Rose <sam@gitlab.com> | 2017-01-12 20:12:46 +0300 |
---|---|---|
committer | samrose3 <sam@gitlab.com> | 2017-01-25 18:46:07 +0300 |
commit | 8010de308eb3fc8da8a1e36c7084d68e7cbf3654 (patch) | |
tree | 40e3d3dcd458166dac0a0a0e6bdd350efe9343d4 /app/assets/javascripts/gl_dropdown.js | |
parent | 37c35b116cd1f0ce38d3d41f981a22d523d88a9b (diff) |
Prevent removing fields from dropdowns on input elements
Diffstat (limited to 'app/assets/javascripts/gl_dropdown.js')
-rw-r--r-- | app/assets/javascripts/gl_dropdown.js | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/app/assets/javascripts/gl_dropdown.js b/app/assets/javascripts/gl_dropdown.js index bb516b3d2df..4f734f6ff62 100644 --- a/app/assets/javascripts/gl_dropdown.js +++ b/app/assets/javascripts/gl_dropdown.js @@ -653,18 +653,14 @@ isMarking = false; el.removeClass(ACTIVE_CLASS); if (field && field.length) { - if (isInput) { - field.val(''); - } else { - field.remove(); - } + this.clearField(field, isInput); } } else if (el.hasClass(INDETERMINATE_CLASS)) { isMarking = true; el.addClass(ACTIVE_CLASS); el.removeClass(INDETERMINATE_CLASS); if (field && field.length && value == null) { - field.remove(); + this.clearField(field, isInput); } if ((!field || !field.length) && fieldName) { this.addInput(fieldName, value, selectedObject); @@ -678,7 +674,7 @@ } } if (field && field.length && value == null) { - field.remove(); + this.clearField(field, isInput); } // Toggle active class for the tick mark el.addClass(ACTIVE_CLASS); @@ -828,6 +824,10 @@ return $(this.el).find(".dropdown-toggle-text").text(this.options.toggleLabel(selected, el, instance)); }; + GitLabDropdown.prototype.clearField = function(field, isInput) { + return isInput ? field.val('') : field.remove(); + }; + return GitLabDropdown; })(); |