Closed rjpmestre closed 5 months ago
@rjpmestre Please share your Livewire component class and view too. So I can test it locally. I think the PR you created is to solve a very particular situation that can be solved by just adding that custom code somewhere in your Livewire component.
Note this package wasn't created initially to fully work with Livewire
, its just an extra tool on Laravel and we just added a configuration to include it easily.
The base example that represent this would be having a./app/Livewire/Inputcolortest.php
:
<?php
namespace App\Livewire;
use Livewire\Component;
class Inputcolortest extends Component
{
public $bgColor = '#ffffff';
public function render()
{
return view('livewire.inputcolortest');
}
}
and a ./resources/views/livewire/inputcolortest.blade.php
:
<div>
<input wire:model.live="bgColor">
<x-adminlte-input-color name="icBasic" wire:model.live="bgColor"/>
</div>
Changing either the input fields should update the other. I ended up adding it just for future reference. Probably someone had the same sort of workaround going on as the one i had on the PR.
But i guess you're right. I've been using your package for a while. It eases so many things and integrates so well I didnt even realize integrating Livewire wasn't a goal. Having this said, I can only be thankfull for your work and dedication mantaining this project.
@rjpmestre I appreciate your thanks, in this case, instead of adding the code in the base component, you might add your workaround in the same Livewire component, for example:
<div>
<input class="mb-3" wire:model.live="bgColor">
<x-adminlte-input-color name="icBasic" wire:model.live="bgColor"/>
</div>
@push('js')
<script>
$(() => {
$('#icBasic').on('colorpickerChange', function(e) {
this.dispatchEvent(new Event('input'));
});
})
</script>
@endpush
Describe the bug
Picking a color on input color component doesnt update the binded livewire component.
Steps To Reproduce
Steps to reproduce the behavior:
bgColor
Expected behavior
Picking a color from the palette should update the property value. I'd expect to see a livewire event being triggered and both input fields having same value.
Screenshots
N/A
Environment
N/A
Additional context
Submitted a suggestion / partial solution at this PR