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

**URL:** <https://discourse.nodered.org/t/is-it-possible-to-stop-edit-dialog-from-closing-when-click-on-done/84780>\
**Category:** Developing Nodes\
**Created:** [21 January 2024 21:10 UTC](https://discourse.nodered.org/t/is-it-possible-to-stop-edit-dialog-from-closing-when-click-on-done/84780 "2024-01-21T21:10:54Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![AGhorab](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/aghorab/32/87562_2.png) [@AGhorab](https://discourse.nodered.org/u/AGhorab)\
**Post date:** [21 January 2024 21:10 UTC](https://discourse.nodered.org/t/is-it-possible-to-stop-edit-dialog-from-closing-when-click-on-done/84780/1 "2024-01-21T21:10:54Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [21 January 2024 21:22 UTC](https://discourse.nodered.org/t/is-it-possible-to-stop-edit-dialog-from-closing-when-click-on-done/84780/2 "2024-01-21T21:22:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![AGhorab](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/aghorab/32/87562_2.png) [@AGhorab](https://discourse.nodered.org/u/AGhorab)\
**Post date:** [21 January 2024 21:26 UTC](https://discourse.nodered.org/t/is-it-possible-to-stop-edit-dialog-from-closing-when-click-on-done/84780/3 "2024-01-21T21:26:29Z")

</div>

i start the validation inside oneditsave function

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

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [21 January 2024 21:28 UTC](https://discourse.nodered.org/t/is-it-possible-to-stop-edit-dialog-from-closing-when-click-on-done/84780/4 "2024-01-21T21:28:33Z")

</div>

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

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

---

<div class="post-metadata">

**Author:** ![GogoVega](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gogovega/32/71313_2.png) [@GogoVega](https://discourse.nodered.org/u/GogoVega)\
**Post date:** [21 January 2024 21:35 UTC](https://discourse.nodered.org/t/is-it-possible-to-stop-edit-dialog-from-closing-when-click-on-done/84780/5 "2024-01-21T21:35:41Z")

</div>

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.

> [@AGhorab](#):
>
> So i was asking is it possible to stop it from closing until I'm done?

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

> [@AGhorab](#):
>
> the other option would be to validate the node after deploy

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

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [22 January 2024 00:19 UTC](https://discourse.nodered.org/t/is-it-possible-to-stop-edit-dialog-from-closing-when-click-on-done/84780/6 "2024-01-22T00:19:10Z")

</div>

> [@AGhorab](#):
>
> i start the validation inside oneditsave function
> 
> so "Done" button is already clicked at that moment.

So just do it earlier! 😀

---

<div class="post-metadata">

**Author:** ![AGhorab](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/aghorab/32/87562_2.png) [@AGhorab](https://discourse.nodered.org/u/AGhorab)\
**Post date:** [22 January 2024 07:29 UTC](https://discourse.nodered.org/t/is-it-possible-to-stop-edit-dialog-from-closing-when-click-on-done/84780/7 "2024-01-22T07:29:48Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![AGhorab](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/aghorab/32/87562_2.png) [@AGhorab](https://discourse.nodered.org/u/AGhorab)\
**Post date:** [22 January 2024 07:33 UTC](https://discourse.nodered.org/t/is-it-possible-to-stop-edit-dialog-from-closing-when-click-on-done/84780/8 "2024-01-22T07:33:53Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![GogoVega](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gogovega/32/71313_2.png) [@GogoVega](https://discourse.nodered.org/u/GogoVega)\
**Post date:** [22 January 2024 08:22 UTC](https://discourse.nodered.org/t/is-it-possible-to-stop-edit-dialog-from-closing-when-click-on-done/84780/9 "2024-01-22T08:22:59Z")

</div>

> [@AGhorab](#):
>
> my other solution would have been loading all the ID and check if it's in them.

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

> [@AGhorab](#):
>
> but with the replace **Done** button with my own that is a nice solution for me.

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

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [22 January 2024 08:53 UTC](https://discourse.nodered.org/t/is-it-possible-to-stop-edit-dialog-from-closing-when-click-on-done/84780/10 "2024-01-22T08:53:10Z")

</div>

> [@GogoVega](#):
>
> 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.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [22 January 2024 13:32 UTC](https://discourse.nodered.org/t/is-it-possible-to-stop-edit-dialog-from-closing-when-click-on-done/84780/11 "2024-01-22T13:32:07Z")

</div>

> [@AGhorab](#):
>
> 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.

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

> [@AGhorab](#):
>
> i already have a registered API that return true or false based on ID.

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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [22 March 2024 13:32 UTC](https://discourse.nodered.org/t/is-it-possible-to-stop-edit-dialog-from-closing-when-click-on-done/84780/12 "2024-03-22T13:32:20Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
