From 78c0924e50fb5be6f4964c9ffef4edc5b03f0319 Mon Sep 17 00:00:00 2001 From: Jairo Llopis Date: Fri, 22 Dec 2023 11:29:14 +0000 Subject: [PATCH] [FIX] web_widget_numeric_step: no input focus on touch screens MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If you're using a tablet and click on the ➕ or ➖ buttons created by this module, the result was that the numeric input related to that button got focused. On tablets, that means that the on-screen keyboard pops up. This usually triggers a layout recalculation and becomes clunky. Besides, it's useless, because if you wanted to use the keyboard, you'd have clicked on the input by yourself, and not in one of those buttons. After this change, when using a touch screen, if you click on the +/- buttons, you won't auto-focus on the input. Thus, the keyboard won't show up. @moduon MT-4472 --- web_widget_numeric_step/README.rst | 2 +- web_widget_numeric_step/__manifest__.py | 2 +- web_widget_numeric_step/static/description/index.html | 2 +- web_widget_numeric_step/static/src/numeric_step.esm.js | 5 ++++- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/web_widget_numeric_step/README.rst b/web_widget_numeric_step/README.rst index 678408d38..48d96b47e 100644 --- a/web_widget_numeric_step/README.rst +++ b/web_widget_numeric_step/README.rst @@ -7,7 +7,7 @@ Web Widget Numeric Step !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:404b377c03eeead0eb7b1dd03b17ecff3a4b72aff56decfdccd33e5bbcf1b8b5 + !! source digest: sha256:cc3d79cf1592294e77da78edc530b91ddfc931abe8f31a361b65ae2f197537b5 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png diff --git a/web_widget_numeric_step/__manifest__.py b/web_widget_numeric_step/__manifest__.py index ee3700455..0186c368d 100644 --- a/web_widget_numeric_step/__manifest__.py +++ b/web_widget_numeric_step/__manifest__.py @@ -5,7 +5,7 @@ { "name": "Web Widget Numeric Step", "category": "web", - "version": "16.0.1.1.0", + "version": "16.0.1.1.1", "author": "GRAP, Tecnativa, " "Odoo Community Association (OCA)", "license": "AGPL-3", "website": "https://github.com/OCA/web", diff --git a/web_widget_numeric_step/static/description/index.html b/web_widget_numeric_step/static/description/index.html index 6231cca13..58adcf326 100644 --- a/web_widget_numeric_step/static/description/index.html +++ b/web_widget_numeric_step/static/description/index.html @@ -366,7 +366,7 @@ ul.auto-toc { !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:404b377c03eeead0eb7b1dd03b17ecff3a4b72aff56decfdccd33e5bbcf1b8b5 +!! source digest: sha256:cc3d79cf1592294e77da78edc530b91ddfc931abe8f31a361b65ae2f197537b5 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

Beta License: AGPL-3 OCA/web Translate me on Weblate Try me on Runboat

This widget changes input number field and make it easier to increment the number thanks to 2 buttons (+ and -). diff --git a/web_widget_numeric_step/static/src/numeric_step.esm.js b/web_widget_numeric_step/static/src/numeric_step.esm.js index 6defd19ec..1522132d2 100644 --- a/web_widget_numeric_step/static/src/numeric_step.esm.js +++ b/web_widget_numeric_step/static/src/numeric_step.esm.js @@ -4,6 +4,7 @@ import {registry} from "@web/core/registry"; import {standardFieldProps} from "@web/views/fields/standard_field_props"; import {_lt} from "@web/core/l10n/translation"; import {FloatField} from "@web/views/fields/float/float_field"; +import {hasTouch} from "@web/core/browser/feature_detection"; export class NumericStep extends FloatField { setup() { @@ -11,7 +12,9 @@ export class NumericStep extends FloatField { } _onStepClick(ev) { const $el = $(ev.target).parent().parent().find("input"); - $el.focus(); + if (!hasTouch()) { + $el.focus(); + } const mode = $(ev.target).data("mode"); this._doStep(mode); }