]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Set focus back to input field after clicking an item 6099/head
authorMarcel Korpel <marcel.korpel@gmail.com>
Sat, 1 Dec 2012 14:19:41 +0000 (15:19 +0100)
committerMarcel Korpel <marcel.korpel@gmail.com>
Sun, 2 Dec 2012 11:35:33 +0000 (12:35 +0100)
Test 'focus is still set' added

Fixes issue #5933

js/bootstrap-typeahead.js
js/tests/unit/bootstrap-typeahead.js

index 2f3dc274f991085766c16d5c8e06153ffdf426bd..4f333e8c23473bc0a42a5087778ca402817406e6 100644 (file)
       e.stopPropagation()
       e.preventDefault()
       this.select()
+      this.$element.focus()
     }
 
   , mouseenter: function (e) {
index 16bdb9194834435f26c4949bad5b83a199f09eea..5e1183609a1e057abdd00b9f57bc8c5127912528 100644 (file)
@@ -162,17 +162,22 @@ $(function () {
             })
           , typeahead = $input.data('typeahead')
           , changed = false
+          , focus = false
+          , blur = false
 
         $input.val('a')
         typeahead.lookup()
 
         $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()
 
         equals($input.val(), 'ac', 'input value was correctly set')
         ok(!typeahead.$menu.is(':visible'), 'the menu was hidden')
         ok(changed, 'a change event was fired')
+        ok(focus && !blur, 'focus is still set')
 
         typeahead.$menu.remove()
       })