From 56f7bad1c3e517e148f3baeee89cb4b5e92b543d Mon Sep 17 00:00:00 2001 From: Jordi Ballester Alomar Date: Fri, 25 May 2018 13:36:26 +0200 Subject: [PATCH] fix tab navigation issue in web_decimal_numpad_dot --- web_decimal_numpad_dot/__manifest__.py | 2 +- web_decimal_numpad_dot/static/src/js/numpad_dot.js | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/web_decimal_numpad_dot/__manifest__.py b/web_decimal_numpad_dot/__manifest__.py index 4864b9fa..7d895998 100644 --- a/web_decimal_numpad_dot/__manifest__.py +++ b/web_decimal_numpad_dot/__manifest__.py @@ -8,7 +8,7 @@ { "name": "Web - Numpad Dot as decimal separator", - "version": "11.0.1.0.1", + "version": "11.0.1.0.2", "license": "AGPL-3", "summary": "Allows using numpad dot to enter period decimal separator", "depends": [ diff --git a/web_decimal_numpad_dot/static/src/js/numpad_dot.js b/web_decimal_numpad_dot/static/src/js/numpad_dot.js index 78b47a24..5d6c2ab4 100644 --- a/web_decimal_numpad_dot/static/src/js/numpad_dot.js +++ b/web_decimal_numpad_dot/static/src/js/numpad_dot.js @@ -9,7 +9,7 @@ odoo.define("web_decimal_numpad_dot.FieldFloat", function (require) { var NumpadDotReplaceMixin = { init: function () { this.events = $.extend({}, this.events, { - "keydown": "numpad_dot_replace", + "keyup": "numpad_dot_replace", }); return this._super.apply(this, arguments); }, @@ -20,7 +20,11 @@ odoo.define("web_decimal_numpad_dot.FieldFloat", function (require) { }, numpad_dot_replace: function (event) { + String.prototype.replaceAt=function(index, replacement) { + return this.substr(0, index) + replacement + this.substr(index + replacement.length); + } // Only act on numpad dot key + event.stopPropagation() if (event.keyCode != 110) { return; } @@ -29,12 +33,8 @@ odoo.define("web_decimal_numpad_dot.FieldFloat", function (require) { to = this.$input.prop("selectionEnd"), cur_val = this.$input.val(), point = this.l10n_decimal_point(); - // Replace selected text by proper character - this.$input.val( - cur_val.substring(0, from) + - point + - cur_val.substring(to) - ); + var new_val = cur_val.replaceAt(from-1, point) + this.$input.val(new_val); // Put user caret in place to = from + point.length this.$input.prop("selectionStart", to).prop("selectionEnd", to);