wireui / wireui

TallStack UI components
https://v1.wireui.dev
MIT License
1.37k stars 167 forks source link

V2 Multi Select with wire:model.live does not react on changes #833

Open nastoychev opened 5 months ago

nastoychev commented 5 months ago

Describe the bug V2 Multi Select with wire:model.live does not react on changes To Reproduce

TestComponent.php

<?php

namespace App\Livewire;

use Livewire\Component;

class TestComponent extends Component
{
    public array $options = [];

    public function checkOptions(): void {
        dump($this->option);
    }

    public function render()
    {
        return view('livewire.test-component');
    }
}

bookie-selector.blade.php


<div>
        <form wire:submit="checkOptions">
        <x-select
            wire:model.live="options"
            label="Select Statuses"
            placeholder="Select many statuses"
            multiselect
            :options="['Active', 'Pending', 'Stuck', 'Done']"
        />
        <button type="submit">Submit</button>
    </form>
</div>

Expected behavior A clear and concise description of what you expected to happen.

Screenshots or Videos If applicable, add screenshots or videos to help explain your problem.

Dependencies

Desktop (If applicable, please complete the following information):

Smartphone (If applicable, please complete the following information):

viliusvsx commented 4 months ago

@nastoychev I think the problem is how you wrote this line: wire:model.live="'$options'"

You should write it like this: wire:model.live="options"

nastoychev commented 4 months ago

@nastoychev I think the problem is how you wrote this line: wire:model.live="'$options'"

You should write it like this: wire:model.live="options"

No, it does not work.

P.p. This reproduction example is one of the many attempts to be copied. I will change the description.

Thank you for that suggestion.

viliusvsx commented 4 months ago

@nastoychev I don't understand why you wrote a dollar sign in wire:model.live. As I can see in your updated code version, an error will still occur if you do not remove the dollar sign

nastoychev commented 4 months ago

@nastoychev I don't understand why you wrote a dollar sign in wire:model.live. As I can see in your updated code version, an error will still occur if you do not remove the dollar sign

Thanks a lot for your review and taking care of the correctness. Now I edited again the example where I added simple submit button which check the $this->options. Still not filling it with chosen options.

Perhaps I saw that in the documentation page there are no examples to the selects with wire:model.live and if it's not integrated we need to know and take care of it. I guess the problem is deeper, because our components are pretty complicated behind the scene. So if @PH7-Jack write also some suggestions will be helpful. image