Skip to content

Commit 1c55c86

Browse files
committed
Merge & tweak closeByClickEvent bug fix. Closes #477
1 parent 2be659e commit 1c55c86

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

js/jquery.keyboard.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,9 @@ http://www.opensource.org/licenses/mit-license.php
162162
tmp = tmp.add(base.el.ownerDocument);
163163
}
164164

165-
var bindings = 'keyup checkkeyboard ';
166-
if(o.closeByClickEvent) {
167-
bindings = 'click ';
168-
} else {
169-
bindings += 'mousedown touchstart ';
165+
var bindings = 'keyup checkkeyboard mousedown touchstart ';
166+
if (o.closeByClickEvent) {
167+
bindings += 'click ';
170168
}
171169
tmp.bind(bindings.split(' ').join(base.namespace + ' '), base.checkClose);
172170

@@ -1613,9 +1611,18 @@ http://www.opensource.org/licenses/mit-license.php
16131611
if ($keyboard.allie) {
16141612
e.preventDefault();
16151613
}
1616-
// send 'true' instead of a true (boolean), the input won't get a 'ui-keyboard-autoaccepted'
1617-
// class name - see issue #66
1618-
base.close(o.autoAccept ? 'true' : false);
1614+
if (o.closeByClickEvent) {
1615+
// only close the keyboard if the user is clicking on an input or if he causes a click
1616+
// event (touchstart/mousedown will not force the close with this setting)
1617+
var name = e.target.nodeName.toLowerCase();
1618+
if (name === 'input' || name === 'textarea' || e.type === 'click') {
1619+
base.close(o.autoAccept ? 'true' : false);
1620+
}
1621+
} else {
1622+
// send 'true' instead of a true (boolean), the input won't get a 'ui-keyboard-autoaccepted'
1623+
// class name - see issue #66
1624+
base.close(o.autoAccept ? 'true' : false);
1625+
}
16191626
}
16201627
};
16211628

0 commit comments

Comments
 (0)