nativescript-datetimepicker icon indicating copy to clipboard operation
nativescript-datetimepicker copied to clipboard

How to clear/reset the component field?

Open baermathias opened this issue 5 years ago • 1 comments

I am using nativescript-vue and several <DatePickerField>'s in a filter/search. After clearing/resetting the filter I need it to show the hint text or an empty field.

When setting date to an empty string :date="''" the component shows the value 01.01.1970, so my method to clear it is by re-rendering the component and give each a key :key="keyVar1" with a random value this.keyVar1 = Math.random().toString(36).substring(2,15);.

Is there a more native method or is re-rendering the way to go here?

baermathias avatar Jun 05 '20 06:06 baermathias

I found out, that it is possible to pass undefined to date:

:date="undefined"

If this happens, the value of hint property will be shown preferred. Imo the same behaviour should happen with null and empty strings. Also this behaviour should be documented somewhere. So another solution can be to set hint to e.g. hint=" " and pass undefinded to date.

Maybe this info helps somebody.

baermathias avatar Jul 09 '20 14:07 baermathias