Introduced an offset limit to prevent the dropdown from going far right

This commit is contained in:
Jose Ivan Vargas 2017-01-20 19:03:59 -06:00 committed by Phil Hughes
parent f6f52b43b5
commit 98dbb8e23d

View file

@ -90,7 +90,15 @@
const input = this.filteredSearchInput; const input = this.filteredSearchInput;
const inputText = input.value.slice(0, input.selectionStart); const inputText = input.value.slice(0, input.selectionStart);
const filterIconPadding = 27; 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); this.mapping[key].reference.setOffset(offset);
} }