This is an automated email from the ASF dual-hosted git repository. vishesh pushed a commit to branch 4.19 in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/4.19 by this push: new 6f03f9e726e validate inserted values in numeric global settings (#10279) 6f03f9e726e is described below commit 6f03f9e726ef099f63e8c92950282950e83e1c80 Author: Bernardo De Marco Gonçalves <bernardomg2...@gmail.com> AuthorDate: Thu Jan 30 08:00:32 2025 -0300 validate inserted values in numeric global settings (#10279) --- ui/src/views/setting/ConfigurationValue.vue | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/ui/src/views/setting/ConfigurationValue.vue b/ui/src/views/setting/ConfigurationValue.vue index 109931a6664..acee0f2eb6a 100644 --- a/ui/src/views/setting/ConfigurationValue.vue +++ b/ui/src/views/setting/ConfigurationValue.vue @@ -39,6 +39,7 @@ @keydown.esc="editableValueKey = null" @pressEnter="updateConfigurationValue(configrecord)" @change="value => setConfigurationEditable(configrecord, value)" + @keydown="e => handleInputNumberKeyDown(e, false)" /> </a-tooltip> </span> @@ -52,6 +53,7 @@ @keydown.esc="editableValueKey = null" @pressEnter="updateConfigurationValue(configrecord)" @change="value => setConfigurationEditable(configrecord, value)" + @keydown="e => handleInputNumberKeyDown(e, true)" /> </a-tooltip> </span> @@ -87,6 +89,7 @@ @keydown.esc="editableValueKey = null" @pressEnter="updateConfigurationValue(configrecord)" @change="value => setConfigurationEditable(configrecord, value)" + @keydown="e => handleInputNumberKeyDown(e, true)" /> </a-tooltip> </a-col> @@ -350,6 +353,26 @@ export default { } else { this.editableValueKey = null } + }, + handleInputNumberKeyDown (event, isDecimal) { + const allowedCodes = ['Backspace', 'Delete', 'ArrowLeft', 'ArrowRight', 'Minus'] + + if (isDecimal) { + allowedCodes.push('Period') + } + + if ( + event.getModifierState('Control') || + event.getModifierState('Meta') || + event.getModifierState('Alt') + ) { + return + } + + const isValid = allowedCodes.includes(event.code) || !isNaN(event.key) + if (!isValid) { + event.preventDefault() + } } } }