symfony / ux

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

[Live Component + Autocomplete + Dynamics form] Change rendering problem #1359

Closed ag-erwan closed 7 months ago

ag-erwan commented 10 months ago

Hello community

I come to you because I have a problem. In addition to the Live Component and Autocomplete libraries, I also use the symfonycast/dynamics-form library, I manage to make my fields show on first change with the data they contain, but when I modify at my selection field again, my other fields appear but do not change. Actually, it's a rendering issue, which means no more re-rendering. Because when I do a dump, I can clearly see the changed data. thank you in advance for your help

smnandre commented 10 months ago

Hello, LiveComponent and Autocomplete are known to form a non-ideal pair :\

Could you produce a small reproducer or explain a bit more your situation ?

ag-erwan commented 10 months ago

Good morning,

Thank you for your reply ! Yes of course I can explain more.

I have two fields, the name field which is an EntityType which retrieves the list of all the names of the users in the database and we can select one of the users, and the roles field which is also an entitytype which retrieves the list of all the roles and you can select one or more roles. The goal is that the roles field only appears when I have selected a user, this role field therefore displays the user's roles if they have any.

The problem is that when I select a user, the role field appears but does not display any roles even though my user has roles. But yet when I dump the role field I see these roles clearly, but it is not displayed in the Twig rendering

UPDATE Small update, I tried to do without the autocomplete and without the symfonycast/dynamics-form library and the data changes when changed, however as soon as I put the dynamics-form library back and when the role field changes does not modify because it tells me that the field does not exist. In fact it first goes through the liveAction in the liveComponent.

I just noticed this in the autocomplete documentation

However, if you use the multiple option, due to complexities in TomSelect, the autocomplete widget will work, but it will not update if you change any options. For example, if your change the "options" for a select during re-render, those will not update on the frontend.

Link

smnandre commented 10 months ago

I'm not sure we can do anything for now about this, due to the problems you mentionned.

We are looking at alternative options but i can't promise you any deadline :/

antoniovj1 commented 6 months ago

I'm facing the same issue. I've been trying to force disconnect and reconnect the Stimulus controller, but with no luck.

For now, I'm going to replace the Autocomplete with my own JS implementation. But if there's anything I can help you with, let me know @smnandre

smnandre commented 6 months ago

I'm not a user of Autocomplete so this is not the component i know the much... so any help would be much welcomed :)