[pve-devel] applied: [PATCH widget-toolkit] text field: add trimValue config

Thomas Lamprecht t.lamprecht at proxmox.com
Tue Oct 24 14:02:12 CEST 2023


Inspired by a recent bug detected in the subscription key field, where
a trailing white space caused verification issues.

We might even enable the trimming by default, after checking call
sites that is – most often one wants to trim the text to be submitted

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---

had that laying around since a while and figured why not, it's opt-in
for now anyway.

 src/form/TextField.js | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/form/TextField.js b/src/form/TextField.js
index 56e5976..7ee95c4 100644
--- a/src/form/TextField.js
+++ b/src/form/TextField.js
@@ -6,6 +6,8 @@ Ext.define('Proxmox.form.field.Textfield', {
 	skipEmptyText: true,
 
 	deleteEmpty: false,
+
+	trimValue: false,
     },
 
     getSubmitData: function() {
@@ -29,6 +31,9 @@ Ext.define('Proxmox.form.field.Textfield', {
 	let me = this;
 
         let value = this.processRawValue(this.getRawValue());
+	if (me.getTrimValue() && typeof value === 'string') {
+	    value = value.trim();
+	}
 	if (value !== '') {
 	    return value;
 	}
-- 
2.39.2






More information about the pve-devel mailing list