symfony / ux

Symfony UX initiative: a JavaScript ecosystem for Symfony
https://ux.symfony.com/
MIT License
787 stars 281 forks source link

[LiveComponent] Update in for loop does not update child elements #145

Open sandoche opened 2 years ago

sandoche commented 2 years ago

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: image

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 image

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

benr77 commented 2 years ago

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.

carsonbot commented 3 months ago

Thank you for this issue. There has not been a lot of activity here for a while. Has this been resolved?

carsonbot commented 2 months ago

Could I get a reply or should I close this?

carsonbot commented 2 months ago

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!