ux
ux copied to clipboard
[LiveComponent] Update in for loop does not update child elements
Hi,
I am working on a demo todo app using LiveComponent. The project is here: https://github.com/sandoche/Symfony-ux-live-component-todo-list/
It looks like this:
I created some filters using this parameter
#[LiveProp(writable: true)]
public $filter;
and using this method
private function loadTasks()
{
if ($this->filter == 'all') {
$this->tasks = $this->taskRepository->findAll();
} else {
$this->tasks = $this->taskRepository->findBy(
['isDone' => $this->filter == 'done' ? true : false]
);
}
}
When I click on one of filter it does show the right number of items. But not the right ones.
This is what I see when I click to do
I should instead see "Ranger voiture" and "Ranger vêtements" that are unchecked.
You can see the code here: https://github.com/sandoche/Symfony-ux-live-component-todo-list/blob/main/src/Components/TodoList.php
I have a similar issue. I have a basket component with OrderLines. Each OrderLine has a child component RemoveEntry, which shows a form with a single submit button.
If I do anything to cause the parent basket component to reload, some of the child components do not show.
Weirdly, the child components that do not show the button, the <form>
element does render, but not the button inside the form - all I see is
<form blah blah>
<div class="form-group"></div>
</form>
The button is defined in the form type class using SubmitType::class
rather than being hard-coded into the Twig template.
Thank you for this issue. There has not been a lot of activity here for a while. Has this been resolved?
Could I get a reply or should I close this?
Hey,
I didn't hear anything so I'm going to close it. Feel free to comment if this is still relevant, I can always reopen!