diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2017-06-09 11:36:56 +0300 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2017-06-09 11:36:56 +0300 |
commit | 288e8c7c42bd9507725637dcf7e5b8e0eaa5229c (patch) | |
tree | 4e63d8f8a13f1254ce2544d5e74dbc1732d4ccba /app/assets | |
parent | 4a22895492fd7e9111f11b6659c31b509995721c (diff) | |
parent | dfa4a440f032020cf000841d7e1c799d142f92c8 (diff) |
Merge branch 'issuable-sidebar-edit-button-field-focus' into 'master'
Fixed dropdown filter input not focusing after transition
Closes #33216
See merge request !12020
Diffstat (limited to 'app/assets')
-rw-r--r-- | app/assets/javascripts/gl_dropdown.js | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/app/assets/javascripts/gl_dropdown.js b/app/assets/javascripts/gl_dropdown.js index d34561e5512..3babe273100 100644 --- a/app/assets/javascripts/gl_dropdown.js +++ b/app/assets/javascripts/gl_dropdown.js @@ -248,7 +248,7 @@ GitLabDropdown = (function() { return function(data) { _this.fullData = data; _this.parseData(_this.fullData); - _this.focusTextInput(); + _this.focusTextInput(true); if (_this.options.filterable && _this.filter && _this.filter.input && _this.filter.input.val() && _this.filter.input.val().trim() !== '') { return _this.filter.input.trigger('input'); } @@ -728,8 +728,20 @@ GitLabDropdown = (function() { return [selectedObject, isMarking]; }; - GitLabDropdown.prototype.focusTextInput = function() { - if (this.options.filterable) { this.filterInput.focus(); } + GitLabDropdown.prototype.focusTextInput = function(triggerFocus = false) { + if (this.options.filterable) { + $(':focus').blur(); + + this.dropdown.one('transitionend', () => { + this.filterInput.focus(); + }); + + if (triggerFocus) { + // This triggers after a ajax request + // in case of slow requests, the dropdown transition could already be finished + this.dropdown.trigger('transitionend'); + } + } }; GitLabDropdown.prototype.addInput = function(fieldName, value, selectedObject) { |