diff options
author | Jacob Schatz <jschatz@gitlab.com> | 2017-01-21 23:14:36 +0000 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2017-01-27 14:09:21 -0500 |
commit | 0161c294975726b9aa25f929b0b6c75d5b181f65 (patch) | |
tree | 926f039e9d4e1b31ebea4c3b007f717904f2e63f | |
parent | c4a9ea6cf74ef2c91dbf438326d8a439166f41d3 (diff) | |
download | gitlab-ce-0161c294975726b9aa25f929b0b6c75d5b181f65.tar.gz |
Merge branch '26618-search-bar-dropdown-offset-should-not-go-past-search-bar-input' into 'master'
Introduced an offset limit to prevent the dropdown from going far right
Closes #26618 and #27023
See merge request !8679
-rw-r--r-- | app/assets/javascripts/filtered_search/filtered_search_dropdown_manager.js.es6 | 10 |
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 a387701c3e3..00e1c28692f 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 @@ -98,7 +98,15 @@ const input = this.filteredSearchInput; const inputText = input.value.slice(0, input.selectionStart); const filterIconPadding = 27; - const offset = gl.text.getTextWidth(inputText, this.font) + filterIconPadding; + let offset = gl.text.getTextWidth(inputText, 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); } |