Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added fix for ignoring shortcut key combinations, added sinon js for unit testing #202

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions js/bootstrap-combobox.js
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,10 @@
break;

default:
this.clearTarget();
this.lookup();
if (!e.altKey && !e.ctrlKey && !e.metaKey) {
this.clearTarget();
this.lookup();
}
}

e.stopPropagation();
Expand Down
3 changes: 3 additions & 0 deletions js/tests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
<link rel="stylesheet" href="vendor/qunit.css" type="text/css" media="screen" />
<script src="vendor/qunit.js"></script>

<!-- sinon -->
<script src="vendor/sinon.js"></script>

<!-- plugin sources -->
<script src="../../js/bootstrap-combobox.js"></script>

Expand Down
21 changes: 21 additions & 0 deletions js/tests/unit/bootstrap-combobox.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,4 +320,25 @@ $(function () {

combobox.$menu.remove()
})

test("should not show menu when shortcut combination query entered", function () {
var $select = $('<select title="A title" disabled><option></option><option>aa</option><option selected>ab</option><option>ac</option></select>')
, $input = $select.combobox().data('combobox').$element
, combobox = $select.data('combobox')
, key_event = $.Event('keyup')
, spy = sinon.spy(combobox, 'lookup')

key_event.keyCode = 65
key_event.ctrlKey = true

$input.trigger(key_event)

equal(spy.callCount, 0, 'lookup not called')
equal(combobox.$menu.find('li').length, 0, 'has 0 items in menu')
equal(combobox.$menu.find('.active').length, 0, 'no items are active')

combobox.$menu.remove()
$select.remove()
combobox.$container.remove()
})
})
Loading