Is it possible to stop Edit dialog from Closing when click on Done?

Hello, I'm currently building a node and it's possible to that i can have an async validation on certain fields that would run during saving of node properties in edit dialog.

So i was asking is it possible to stop it from closing until I'm done?

the other option would be to validate the node after deploy but wanted to make it visible to the user ASAP.

You can turn off the "Done" button using jQuery.

i start the validation inside oneditsave function

so "Done" button is already clicked at that moment.

What validation exactly is occurring?
Node RED already provides the validation tools.

And will be highlighted / and alerted to for the user on save

By validation, do you want to validate an input (typedInput) or validate the node?

The validate functions defined in defaults are called during node validation.

The node validation is triggered after the oneditsave event, you can validate an input during this event but it amounts to validating twice.

Possible if your validation is synchronous, the editor is closed as soon as the validation has finished.

This is not possible because the DOM element is destroyed (the editor is closed)

So just do it earlier! :grinning:

i used you idea of disable the button and created a new button (using .clone from jQuery) from Done and hide the original and run the code i need then fire the click event on Done.

i'm using typed input when posibble

but the validation that i run for example (the user can enter an existing id on DB) i need to validate that it's valid.

i already have a registered API that return true or false based on ID.

the issue is all validate method (either in defaults or typedInput) are sync methods that doesn't wait for any asynchronous action to check if it's valid or not.

my other solution would have been loading all the ID and check if it's in them.

but with the replace Done button with my own that is a nice solution for me.

This is a solution, you load your IDs during oneditprepare which you store in the editor and like that your validations will be sync.

The problem is that the user will have a node that does not react like the others

And make sure to advise in your read me that you hack the editor, to achieve what you need.
so they know to report on your GitHub issues page when a problem occurs in the editor window, instead of here.

Sorry - that was a little spicy i know, but I'm not a fan of hacking the editor.


Depending on what you are allowing in the typed input, it might never be possible to validate in the Editor.

Then all you need to do is call that using a synchronous XHR request, you don't need async at all unless that API is super slow.

I have similar API's in UIBUILDER and this is how I do it.

Sounds like you probably don't need to use Typed Input either - that is a large overhead if you aren't using its features and if you are, you might well have inputs that can only be validated by the runtime and not in the editor.