Skip to content
Snippets Groups Projects
Commit a30d9aa5 authored by Adrien Dieudonne's avatar Adrien Dieudonne
Browse files

[FIX] barcodes: avoid virtual keyboard to show up while scanning barcode

(1) Before this commit, the input barcode was removed from the dom
after each scan but now we want to keep it focused to avoid to
automatically open the virtual keyboard in mobile.
This behavior will be useful in enterprise only.
Another commit will follow in this repository.

As the input is not removed anymore, we had to disable autocomplete
to hide previous entries as suggestions.

(2) We also add z-index property to avoid to click on the hidden input
located in the middle of the page.
parent 4a1bc459
No related branches found
No related tags found
No related merge requests found
......@@ -64,12 +64,14 @@ var BarcodeEvents = core.Class.extend(mixins.PropertiesMixin, {
'position': 'fixed',
'top': '50%',
'transform': 'translateY(-50%)',
'opacity': 0,
'z-index': '-1',
},
});
// Avoid to show autocomplete for a non appearing input
this.$barcodeInput.attr('autocomplete', 'off');
}
this.__removeBarcodeField = _.debounce(this._removeBarcodeField, this.inputTimeOut);
this.__blurBarcodeInput = _.debounce(this._blurBarcodeInput, this.inputTimeOut);
},
handle_buffered_keys: function() {
......@@ -232,7 +234,7 @@ var BarcodeEvents = core.Class.extend(mixins.PropertiesMixin, {
this.max_time_between_keys_in_ms);
}
// if the barcode input doesn't receive keydown for a while, remove it.
this.__removeBarcodeField();
this.__blurBarcodeInput();
}
},
......@@ -247,21 +249,22 @@ var BarcodeEvents = core.Class.extend(mixins.PropertiesMixin, {
var barcodeValue = this.$barcodeInput.val();
if (barcodeValue.match(this.regexp)) {
core.bus.trigger('barcode_scanned', barcodeValue, $(e.target).parent()[0]);
this.$barcodeInput.val('');
this._blurBarcodeInput();
}
},
/**
* Remove the temporary input created to store the barcode value.
* If nothing happens, this input will be removed, so the focus will be lost
* and the virtual keyboard on mobile devices will be closed.
* Removes the value and focus from the barcode input.
* If nothing happens, the focus will be lost and
* the virtual keyboard on mobile devices will be closed.
*
* @private
*/
_removeBarcodeField: function () {
_blurBarcodeInput: function () {
if (this.$barcodeInput) {
// Reset the value and remove from the DOM.
this.$barcodeInput.val('').remove();
// Close the virtual keyboard on mobile browsers
// FIXME: actually we can't prevent keyboard from opening
this.$barcodeInput.val('').blur();
}
},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment