wotamann / vuetify-form-base

Schema-based Form Generator - Vue.js 2.0 Component based on Vuetify 2.0
https://wotamann.github.io/vuetify
232 stars 64 forks source link

Clearing date picker doesn't clear the model value #104

Open freestyledork opened 3 years ago

freestyledork commented 3 years ago

When setting the date-picker text field to be clearable the value is cleared but not updated on the form model. You can inspect the same behavior on the demo using the time picker via https://wotamann.github.io/pickers .

I was able to listen to an event by adding changing:

                <v-menu
                  v-else-if="isDateTimeColorTypeAndExtensionText(obj)"
                  v-bind="bindSchemaMenu(obj)"
                >
                  <template v-slot:activator="{ on }">
                    <v-text-field
                      v-on="on"
                      v-bind="bindSchemaText(obj)"
                      :value="setValue(obj)"
                      @[suspendClickAppend(obj)]="onEvent($event, obj, append)"
                      @click:append-outer="onEvent($event, obj, appendOuter)"
                      @click:prepend="onEvent($event, obj, prepend)"
                      @click:prepend-inner="onEvent($event, obj, prependInner)"
                      @click:clear="onEvent($event, obj, clear)"    // <------------------ ADDED THIS
                    />
                    <!-- SLOTS append|prepend|message for picker not avilable, try custom component -->
                  </template>
                  <component
                    :is="mapTypeToComponent( obj.schema.type )"
                    v-bind="bindSchema(obj)"
                    :type="checkInternType(obj)"
                    :value="setValue(obj)"
                    @input="onInput($event, obj)"
                    @click:hour="onEvent({type:'click'}, obj, hour)"
                    @click:minute="onEvent({type:'click'}, obj, minute)"
                    @click:second="onEvent({type:'click'}, obj, second)"
                  />
                </v-menu>

Ideally the form should update the model on a clear event, but by using the added event I was able to handle the clear manually. If you have time it would be awesome if you could update the core to handle this more elegantly. thanks