From 170aa051825cbb6ebd7c3a613c73ee8f466b875c Mon Sep 17 00:00:00 2001 From: Joseph Caburnay Date: Tue, 26 Jul 2022 08:46:55 +0000 Subject: [PATCH] [FIX] point_of_sale: popup behavior on text fields The top popup, by default, confirm/cancel when Enter/Esc key is pressed. This behaviour should be ignored when the focus is in text input fields. closes odoo/odoo#96769 X-original-commit: 29b34ff8d6ee368add91f58cc4db9533d2779a77 Signed-off-by: Trinh Jacky (trj) Signed-off-by: Joseph Caburnay (jcb) --- .../point_of_sale/static/src/js/Popups/PosPopupController.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/point_of_sale/static/src/js/Popups/PosPopupController.js b/addons/point_of_sale/static/src/js/Popups/PosPopupController.js index 1a4eba4c962..dc47d155ab5 100644 --- a/addons/point_of_sale/static/src/js/Popups/PosPopupController.js +++ b/addons/point_of_sale/static/src/js/Popups/PosPopupController.js @@ -62,7 +62,10 @@ odoo.define('point_of_sale.PosPopupController', function(require) { } } _onWindowKeyup(event) { - if (!this.topPopup) return; + const eventIsFromInputField = event.target.tagName === 'INPUT' || event.target.tagName === 'TEXTAREA'; + const shouldHandleKey = this.topPopup && !eventIsFromInputField; + if (!shouldHandleKey) return; + if (event.key === this.topPopup.props.cancelKey) { this.env.posbus.trigger(`cancel-popup-${this.topPopup.props.id}`); } else if (event.key === this.topPopup.props.confirmKey) {