mirror of
https://github.com/twbs/bootstrap.git
synced 2025-02-23 18:40:03 +00:00
Set focus back to input field after clicking an item
Test 'focus is still set' added Fixes issue #5933
This commit is contained in:
parent
3b3dd3ac3c
commit
0dece7a71f
1
js/bootstrap-typeahead.js
vendored
1
js/bootstrap-typeahead.js
vendored
@ -263,6 +263,7 @@
|
|||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
this.select()
|
this.select()
|
||||||
|
this.$element.focus()
|
||||||
}
|
}
|
||||||
|
|
||||||
, mouseenter: function (e) {
|
, mouseenter: function (e) {
|
||||||
|
5
js/tests/unit/bootstrap-typeahead.js
vendored
5
js/tests/unit/bootstrap-typeahead.js
vendored
@ -162,17 +162,22 @@ $(function () {
|
|||||||
})
|
})
|
||||||
, typeahead = $input.data('typeahead')
|
, typeahead = $input.data('typeahead')
|
||||||
, changed = false
|
, changed = false
|
||||||
|
, focus = false
|
||||||
|
, blur = false
|
||||||
|
|
||||||
$input.val('a')
|
$input.val('a')
|
||||||
typeahead.lookup()
|
typeahead.lookup()
|
||||||
|
|
||||||
$input.change(function() { changed = true });
|
$input.change(function() { changed = true });
|
||||||
|
$input.focus(function() { focus = true; blur = false });
|
||||||
|
$input.blur(function() { blur = true; focus = false });
|
||||||
|
|
||||||
$(typeahead.$menu.find('li')[2]).mouseover().click()
|
$(typeahead.$menu.find('li')[2]).mouseover().click()
|
||||||
|
|
||||||
equals($input.val(), 'ac', 'input value was correctly set')
|
equals($input.val(), 'ac', 'input value was correctly set')
|
||||||
ok(!typeahead.$menu.is(':visible'), 'the menu was hidden')
|
ok(!typeahead.$menu.is(':visible'), 'the menu was hidden')
|
||||||
ok(changed, 'a change event was fired')
|
ok(changed, 'a change event was fired')
|
||||||
|
ok(focus && !blur, 'focus is still set')
|
||||||
|
|
||||||
typeahead.$menu.remove()
|
typeahead.$menu.remove()
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user