"Only run if" fails

Hi - me again :see_no_evil:

Is this a bug, or am i doing anything wrong? You can reproduce this with any text input. If you need to reference to the invalid-property or even to the value of the same textbox, it does not work!

To be more clear, i have following scenario for you:

You can see here, i am calling a query onBlur. But i set the "Only run if" to the negated invalid-property. At the moment of the picture, invalid is true, so the call shouldn't have been done. But it fired! Even if i give a debounce on it! I thought, it is just a timing issue.. But you can wait for 10 seconds, IT WILL FIRE, although it does not have to!

Thanks for any advice!

Edit: I now know WHY this happens, but i don't know what do do as a workaround! :unamused:
This happens, because the event handler of a same object can only read the property from BEFORE editing.

Example: Lets say, you have a textbox, with a validation for at least 2 characters. Bind an event... lets say... onChange.

  1. Enter the text field for the first time, type ONE character -> validation message appers, invalid-property gets TRUE, event is being fired. WHAAAAT? :scream:
  2. Enter a SECOND character -> validation message hides, invalid-property gets FALSE, guess what: event is NOT being fired. WHAAAT? NOW IT SHOULD! :woozy_face:
  3. Enter a THIRD character -> no changes on validation meassage and invalid-property, but event will be fired. :clap:t3: :interrobang:

Why is this? Because it is referenced to its own properties/values, which is one step behind. Retool does not recognize the ACTUAL property/value, but from one change before...

So for now, i am 99% sure, this is a bug. But does anyone have a solution for that? I need to finish it by the end of the week and have a lot of this scenarios!

I found again a solution for me. But please tell me if you flagged this as a bug. Should not need a workaround.

For those, who are interested in "my solution":

Of course, i could call a js-query inbetween which reads the correct state and then calls the update-query.. Would be okay for one field, but not for 10, 20 or so.. So my Solution is, to not call a query with the select-field inside the event handler modal, but choose "Run script" and do it there. The code can be copied for all fields. But it still needs a little debounce:

Hey @SIMTEC-Software-Solutions!

Happy to help here! I'm having a hard time reproducing this on our end. Is this query currently set to run on input change by chance? In my test setup, I set a textInput component to validate on 5 characters:

I also added an event handler to fire confetti on blur if the input is valid:

Is this similar to your setup?

\

Hey Chris! Glad to read from you! :smiley:

My query is set to "only if manually triggered". Thanks for your example. It seems, that only the "Special text inputs" have this problem.

I did the same with "editableText" (Sorry, compressor does not make the best gif's):

Bildschirmaufnahme 2021-10-26 um 11.26.44-Animiertes Bild (Klein)

Hmm, testing this on our end with a editableText field and the same setup, but instead an event handler to trigger a JS query (manually triggered) on change I seem to get the same result :thinking:. Would you mind sharing a little more about the query you're triggering here?

You cant see it exactly on the (very poor) .gif video. But it is only confetti, no query trigger!

  • editable Textfield
  • Validation min 5 characters
  • Event onBlur with confetti
  • Only run if !invalid

Confetti will not fire at count 5, but at count 6. AND: If i empty the field again! So there are two corrupt runs.

What i originally wanted to achieve, is an update of user data:

Hey SIMTEC-Software-Solutions. I have tested this setup on my end and am unable to reproduce the behavior you're describing. The editableText.invalid seems to correctly prevent the query from being triggered on blur. Are you still seeing this issue on your end? If so could you share an export of the app where you're seeing this behavior so that I can be sure my setup is exactly the same as yours? You can export your apps by clicking the 3 dots in the top right corner of the app > Export to JSON.

Then, you can import this JSON file by clicking Create new (home page) > Import an app.