vue-dynamic-forms
vue-dynamic-forms copied to clipboard
Setting a field to empty doesn't emit change event
Describe the bug When a user types into an input box it emits a "change" event. If the field is set to "" the change event isn't fired.
To Reproduce
- Create project with
@nextbranch. - Fill a field with text
- Empty field
- See the field is still showing the previous string
Expected behavior The field to be cleared and the change event to be fired.
Additional context The sandbox doesn't have this issue and I believe that's because it's still using the vue 2 version.
https://github.com/asigloo/vue-dynamic-forms/blob/main/src/composables/useInputEvents.ts#L94
The hasValue(curr) check needs to be removed.
It looks like there are 3 places that need the check removed:
- [ ] https://github.com/asigloo/vue-dynamic-forms/blob/main/src/composables/useInputEvents.ts#L94
- [ ] https://github.com/asigloo/vue-dynamic-forms/blob/main/src/composables/useInputEvents.ts#L32
- [ ] https://github.com/asigloo/vue-dynamic-forms/blob/main/src/composables/useDynamicForm.ts#L181
I'm curious if this is a desired change that could be implemented? I'm happy to implement it, however it looks like there are unit tests checking that this functionality "works" and I don't have the context on why it was implemented this way in the first place.
Maybe @alvarosaburido can comment?