Description
Hi,
I've got a LiveComponent
with two selects whose have data-model
on them. First one to choose a "groupType", second one to choose a "companyGroup". "companyGroup" is the one with autocomplete
.
So when I change my groupType, my companyGroups list has to change too. But when I change the groupType, it actually launch an infinite loop of requests on my component...
Here is my code :
Component :
#[LiveProp(writable: true)]
public ?CompanyGroupType $companyGroupType = null;
#[LiveProp(writable: true)]
public ?CompanyGroup $companyGroup = null;
#[LiveAction]
public function onCompanyGroupTypeUpdated(): void
{
$this->companyGroups = $this->groupRepository->findByType($this->companyGroupType);
$this->companyGroup = $this->companyGroups[0];
}
Twig :
<select class="form-control" data-model="companyGroupType" data-action="live#action" data-action-name="onCompanyGroupTypeUpdated">
{% for type in groupTypes %}
<option value="{{ type.id }}">
{{ type.name }}
</option>
{% endfor %}
</select>
<select class="form-control my-1" data-model="companyGroup" {{ stimulus_controller('symfony/ux-autocomplete/autocomplete') }}>
{% for group in companyGroups %}
<option id="{{ group.id }}" value="{{ group.id }}">
{{ group.name }}
</option>
{% endfor %}
</select>
Screen of the console after changed the first select :
I tried with a data-action
instead of data-model="companyGroup"
to manually change companyGroup value, same problem.
If I remove the {{ stimulus_controller('symfony/ux-autocomplete/autocomplete') }}
everything work well (but no autocomplete...)
If i downgrade symfony/ux-autocomplete
to 2.13.3 it works well too.
I know autocomplete and liveComponent not work very well together, but maybe is there something I miss to make this work ?
Thanks,
Pierre