From 34ed9c5cd81e70fb12b49a7b36a074ae099d04f3 Mon Sep 17 00:00:00 2001 From: GogoVega <92022724+GogoVega@users.noreply.github.com> Date: Mon, 3 Jun 2024 18:41:40 +0200 Subject: [PATCH] Don't use the typedInput tooltip to get the validation message --- .../editor-client/src/js/ui/common/typedInput.js | 7 +++++-- .../@node-red/editor-client/src/js/ui/editor.js | 11 +++-------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/common/typedInput.js b/packages/node_modules/@node-red/editor-client/src/js/ui/common/typedInput.js index 013e5098c..db678e6b1 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/common/typedInput.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/common/typedInput.js @@ -1543,7 +1543,7 @@ } } }, - validate: function() { + validate: function(options) { let valid = true; const value = this.value(); const type = this.type(); @@ -1580,7 +1580,10 @@ tooltip.delete(); } } - // Must return a boolean + if (options.returnErrorMessage === true) { + return valid; + } + // Must return a boolean for no 3.x validator return (typeof valid === "string") ? false : valid; }, show: function() { diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/editor.js b/packages/node_modules/@node-red/editor-client/src/js/ui/editor.js index e5247fbd8..72e3044e8 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/editor.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/editor.js @@ -190,14 +190,9 @@ RED.editor = (function() { const input = $("#"+prefix+"-"+property); const isTypedInput = input.length > 0 && input.next(".red-ui-typedInput-container").length > 0; if (isTypedInput) { - valid = input.typedInput("validate"); - if (valid === false) { - // Try to find validation message in the tooltip - const tooltip = input.data("tooltip"); - if (tooltip) { - const content = tooltip.getContent(); - valid = label ? label + ": " + content : content; - } + valid = input.typedInput("validate", { returnErrorMessage: true }); + if (typeof valid === "string") { + valid = label ? label + ": " + valid : valid; } } }