aboutsummaryrefslogtreecommitdiff
path: root/js/tests/unit/dropdown.js
diff options
context:
space:
mode:
authorMark Otto <[email protected]>2014-11-11 19:25:16 -0800
committerMark Otto <[email protected]>2014-11-11 19:25:16 -0800
commit1e268ddfc30def5f4b2b0f2ace34b7de549ea830 (patch)
tree7cc63bc43a6c3b603cef4f004a2285e5c034a710 /js/tests/unit/dropdown.js
parent4f6aeaa6347725436296131c4d2b059243390a04 (diff)
parent001d5e00c58bbb8e4d34c085c5b27b214a475bd5 (diff)
downloadbootstrap-1e268ddfc30def5f4b2b0f2ace34b7de549ea830.tar.xz
bootstrap-1e268ddfc30def5f4b2b0f2ace34b7de549ea830.zip
Merge branch 'master' into labels-readme
Diffstat (limited to 'js/tests/unit/dropdown.js')
-rw-r--r--js/tests/unit/dropdown.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/js/tests/unit/dropdown.js b/js/tests/unit/dropdown.js
index 335795fde..3cdf637ee 100644
--- a/js/tests/unit/dropdown.js
+++ b/js/tests/unit/dropdown.js
@@ -224,4 +224,45 @@ $(function () {
$(document.body).click()
})
+ test('should ignore keyboard events within <input>s and <textarea>s', function () {
+ stop()
+
+ var dropdownHTML = '<ul class="tabs">'
+ + '<li class="dropdown">'
+ + '<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown</a>'
+ + '<ul class="dropdown-menu" role="menu">'
+ + '<li><a href="#">Secondary link</a></li>'
+ + '<li><a href="#">Something else here</a></li>'
+ + '<li class="divider"/>'
+ + '<li><a href="#">Another link</a></li>'
+ + '<li><input type="text" id="input"></li>'
+ + '<li><textarea id="textarea"/></li>'
+ + '</ul>'
+ + '</li>'
+ + '</ul>'
+ var $dropdown = $(dropdownHTML)
+ .appendTo('#qunit-fixture')
+ .find('[data-toggle="dropdown"]')
+ .bootstrapDropdown()
+
+ var $input = $('#input')
+ var $textarea = $('#textarea')
+
+ $dropdown
+ .parent('.dropdown')
+ .on('shown.bs.dropdown', function () {
+ ok(true, 'shown was fired')
+
+ $input.focus().trigger($.Event('keydown', { which: 38 }))
+ ok($(document.activeElement).is($input), 'input still focused')
+
+ $textarea.focus().trigger($.Event('keydown', { which: 38 }))
+ ok($(document.activeElement).is($textarea), 'textarea still focused')
+
+ start()
+ })
+
+ $dropdown.click()
+ })
+
})