[FIX] barcodes: allow users to 'click' focused buttons with Return

Return key events don't get redispatched and even if they did, it
wouldn't work because 'fake' keypress events don't trigger native HTML
event handlers.

This should be safe because Return cannot start a valid barcode.
This commit is contained in:
Joren Van Onder
2016-07-13 13:58:50 +02:00
parent 4dc228d01c
commit c902437247
@@ -129,6 +129,10 @@ var BarcodeEvents = core.Class.extend(mixins.PropertiesMixin, {
// Don't catch keypresses which could have a UX purpose (like shortcuts)
if (e.ctrlKey || e.metaKey || e.altKey)
return;
// Don't catch Return when nothing is buffered. This way users
// can still use Return to 'click' on focused buttons or links.
if (e.which === 13 && this.buffered_key_events.length === 0)
return;
// Don't catch events targeting elements that are editable because we
// have no way of redispatching 'genuine' key events. Resent events
// don't trigger native event handlers of elements. So this means that