Files
zulip/static/js/keydown_util.js
Shubham Dhama 51ae82fbcf left-sidebar: Fix opening of compose box on narrowing using hotkeys.
Explaining the problem a bit: When we narrow to a stream/private message
using `q+Enter`/`w+Enter` compose box opens which isn't desirable here.
The bug here was the propagation of event after getting handled in
`keydown_util.handle` to `hotkeys.process_enter_key`.

Fixes: #9679.
2018-06-09 12:53:24 -04:00

46 lines
773 B
JavaScript

var keydown_util = (function () {
var exports = {};
/*
See hotkey.js for handlers that are more app-wide.
*/
var keys = {
13: 'enter_key',
37: 'left_arrow',
38: 'up_arrow',
39: 'right_arrow',
40: 'down_arrow',
};
exports.handle = function (opts) {
opts.elem.keydown(function (e) {
var key = e.which || e.keyCode;
var key_name = keys[key];
if (!key_name) {
return;
}
if (!opts.handlers[key_name]) {
return;
}
var handled = opts.handlers[key_name]();
if (handled) {
e.preventDefault();
e.stopPropagation();
}
});
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = keydown_util;
}