提交 995d4df1 编写于 作者: B Bryce Johnson

Ensure cursor is applied to end of issues search input.

上级 e0a79ab4
......@@ -53,8 +53,22 @@
}
},
maybeFocusOnSearch: function() {
if (Issuable.searchState.current !== '') {
Issuable.searchState.elem.focus();
const currentSearchVal = Issuable.searchState.current;
if (currentSearchVal !== '') {
const queryLength = currentSearchVal.length;
const $searchInput = Issuable.searchState.elem;
/* The following ensures that the cursor is initially placed at
* the end of search input when focus is applied. It accounts
* for differences in browser implementations of `setSelectionRange`
* and cursor placement for elements in focus.
*/
$searchInput.focus();
if ($searchInput.setSelectionRange) {
$searchInput.setSelectionRange(queryLength, queryLength);
} else {
$searchInput.val(currentSearchVal);
}
}
},
executeSearch: function(e) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册