Clear button set value to default value

Hi,
If I hit the clear button in a select field. The value of this field is set to null instead of the default value. How can this be done?

Thanks in advance for your help.
Best,
Thomas

Hey Thomas! I don’t think there’s a built-in way to do this, but you can make this happen with an event handler.

On your select component, if you add an event handler, set the event to “Clear”, and have it run script:

select1.setValue(“your default value”)

then it should work as expected!

Let me know if you have any questions getting this set up.

Thanks Victoria for the solution, however on my side, I don't find any event related to the "clear" action, cf the screenshot below. Is there something I do wrongly?
If it has changed, is there another way to do it ?
image
Thanks for your help

Hi @Jumo, welcome to the forum! :wave:

Since we don't have a Clear event handler, we could achieve this by running a script instead.

For example, my "Select" component has a default value of "Option 1." I added an event handler to run on change, but only if the value becomes null, which will happen when the user clicks the clear button.

To do this, add that condition to the "Only run when" field of the event handler:

Let us know if you have any questions! :slightly_smiling_face: