Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: live mode for datepicker range mode (#653)
* feat: live mode for datepicker range mode Using `wire:model.live` makes datepicker with mode set to `range` behave unexpectedly as described in #649. This is due to livewire sending update as long as the user selects the first date. I can't find anyway to customize the behavior of livewire's `.live` modefier. My proposed fix for instances when you want live update as long as the user selects a range is to add a `live` attribute to datepicker. This will add a change event listener using `x-on:change` which checks if the date is complete by spliting it with `'to'` and checking if the resulting array contains two items. The listener only gets attached if the mode is set to range, hence making the live attribute range mode exclusive. * feat: remove live attribute This makes the `wire:model.live` work seemlessly if the `mode` is set `range`. This implementation checks if `mode` is set to `range` and the `wire:model.live` attribute is present, then it rewrites the attribute but setting it back to `wire:model` and adding a new attribute called `live` which is used to check weather or not to attach the `x-on:change` listener since we will removed the `wire:model.live` in the setup function. * WIP --------- Co-authored-by: Robson Tenório <rrtenorio@gmail.com>
- Loading branch information