From 90ef4d4f3cf3e866076397803be455e9d4f6a42a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20=C3=89vrard?= Date: Mon, 15 Apr 2024 20:28:57 +0200 Subject: [PATCH 1/3] Fix size of char inputs when the size is set [PREVIEW] --- sao/src/view/form.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sao/src/view/form.js b/sao/src/view/form.js index a4b1f6f43d9..ef58bfab899 100644 --- a/sao/src/view/form.js +++ b/sao/src/view/form.js @@ -1997,6 +1997,8 @@ function eval_pyson(value){ if (!attributes.size) { this.group.css('width', '100%'); + } else { + this.input.css('box-sizing', 'content-box'); } if (this.attributes.translate) { Sao.common.ICONFACTORY.get_icon_img('tryton-translate') @@ -2047,6 +2049,10 @@ function eval_pyson(value){ length = record.expr_eval(this.attributes.size); if (length > 0) { width = null; + this.input.css({ + 'width': `${length}ch`, + 'min-width': `${length}ch`, + }); } } this.input.val(this.get_client_value()); From 8fe418ff36ae6ee2df08d00b8b6cd3309f92bf0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20=C3=89vrard?= Date: Wed, 17 Apr 2024 10:24:30 +0200 Subject: [PATCH 2/3] Use the same implementation as upstream --- sao/src/view/form.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/sao/src/view/form.js b/sao/src/view/form.js index ef58bfab899..125c6cf7187 100644 --- a/sao/src/view/form.js +++ b/sao/src/view/form.js @@ -1997,8 +1997,6 @@ function eval_pyson(value){ if (!attributes.size) { this.group.css('width', '100%'); - } else { - this.input.css('box-sizing', 'content-box'); } if (this.attributes.translate) { Sao.common.ICONFACTORY.get_icon_img('tryton-translate') @@ -2048,11 +2046,7 @@ function eval_pyson(value){ if (record) { length = record.expr_eval(this.attributes.size); if (length > 0) { - width = null; - this.input.css({ - 'width': `${length}ch`, - 'min-width': `${length}ch`, - }); + width = (length + 5) + 'ch'; } } this.input.val(this.get_client_value()); @@ -2496,6 +2490,7 @@ function eval_pyson(value){ if (this.width !== null){ this.input_text.css('width', this.width + 'ch'); this.input.css('width', (this.width + 5) + 'ch'); + this.group.css('width', (this.width + 5) + 'ch'); } if (field) { value = field.get_client(record, this.factor, this.grouping); From a135a11465604276051a883cddf2d41e11b54038 Mon Sep 17 00:00:00 2001 From: Jean Cavallo Date: Tue, 23 Apr 2024 21:20:10 +0200 Subject: [PATCH 3/3] Actual fix, tighter fit --- sao/src/theme/coog/sao.less | 10 +++++++++- sao/src/view/form.js | 6 +++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/sao/src/theme/coog/sao.less b/sao/src/theme/coog/sao.less index 2bd25c35f01..ccd3807f24e 100644 --- a/sao/src/theme/coog/sao.less +++ b/sao/src/theme/coog/sao.less @@ -561,7 +561,7 @@ div.form-boolean > input[type=checkbox].input-checkbox.form-control[readonly] { // increase minimum width of fields .form { - .form-char, .form-password, .form-integer, .form-float, + .form-password, .form-float, .form-datetime, .form-time, .form-timedelta, .form-selection, .form-multiselection, .form-url, .form-email, .form-callto, .form-sip, .form-pyson { @@ -569,6 +569,14 @@ div.form-boolean > input[type=checkbox].input-checkbox.form-control[readonly] { min-width: 17ch; } } + .form-char, .form-integer { + input:not([size]) { + min-width: 17ch; + } + input[size] { + min-width: unset; + } + } .form-many2one, .form-one2one, .form-reference, form-binary { select { min-width: 15ch; diff --git a/sao/src/view/form.js b/sao/src/view/form.js index 125c6cf7187..50aada2dc23 100644 --- a/sao/src/view/form.js +++ b/sao/src/view/form.js @@ -2046,7 +2046,7 @@ function eval_pyson(value){ if (record) { length = record.expr_eval(this.attributes.size); if (length > 0) { - width = (length + 5) + 'ch'; + width = (length + 2) + 'ch'; } } this.input.val(this.get_client_value()); @@ -2489,8 +2489,8 @@ function eval_pyson(value){ var value = ''; if (this.width !== null){ this.input_text.css('width', this.width + 'ch'); - this.input.css('width', (this.width + 5) + 'ch'); - this.group.css('width', (this.width + 5) + 'ch'); + this.input.css('width', (this.width + 2) + 'ch'); + this.group.css('width', (this.width + 2) + 'ch'); } if (field) { value = field.get_client(record, this.factor, this.grouping);