summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJose Ivan Vargas <jvargas@gitlab.com>2017-01-20 19:03:59 -0600
committerJose Ivan Vargas <jvargas@gitlab.com>2017-01-20 19:03:59 -0600
commitb1285f0a366c51dd6361cfd49c287d71c5559abe (patch)
tree979254a6f507c31e52d3d655cc2add42a22fff90
parent3975ee57e34d355e86adf4977feff4fd5ab5d130 (diff)
downloadgitlab-ce-26618-search-bar-dropdown-offset-should-not-go-past-search-bar-input.tar.gz
Introduced an offset limit to prevent the dropdown from going far right26618-search-bar-dropdown-offset-should-not-go-past-search-bar-input
-rw-r--r--app/assets/javascripts/filtered_search/filtered_search_dropdown_manager.js.es610
1 files changed, 9 insertions, 1 deletions
diff --git a/app/assets/javascripts/filtered_search/filtered_search_dropdown_manager.js.es6 b/app/assets/javascripts/filtered_search/filtered_search_dropdown_manager.js.es6
index 1cd0483877a..83eb1864f5c 100644
--- a/app/assets/javascripts/filtered_search/filtered_search_dropdown_manager.js.es6
+++ b/app/assets/javascripts/filtered_search/filtered_search_dropdown_manager.js.es6
@@ -91,9 +91,17 @@
}
const filterIconPadding = 27;
- const offset = gl.text
+ let offset = gl.text
.getTextWidth(this.filteredSearchInput.value, this.font) + filterIconPadding;
+ const currentDropdownWidth = this.mapping[key].element.clientWidth === 0 ? 200 :
+ this.mapping[key].element.clientWidth;
+ const offsetMaxWidth = this.filteredSearchInput.clientWidth - currentDropdownWidth;
+
+ if (offsetMaxWidth < offset) {
+ offset = offsetMaxWidth;
+ }
+
this.mapping[key].reference.setOffset(offset);
}