Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LiveComponent] Sharing templates between child components broken since 2.14 #1470

Closed
tijnema opened this issue Feb 7, 2024 · 6 comments · Fixed by #1484
Closed

[LiveComponent] Sharing templates between child components broken since 2.14 #1470

tijnema opened this issue Feb 7, 2024 · 6 comments · Fixed by #1484
Labels
Bug Bug Fix Status: Needs Review Needs to be reviewed

Comments

@tijnema
Copy link

tijnema commented Feb 7, 2024

Since live component 2.14 we can no longer use child components inside a parent component with the same template. The child components will generate the same live id.

I've created a reproducer here: https://github.com/tijnema/livebug
In the current state it shows how it should work (live components version 2.13), pressing the button will render child A or B.
Upgrading live components to 2.14 breaks it, and will either render the wrong component, or render nothing at all.

@smnandre
Copy link
Collaborator

smnandre commented Feb 7, 2024

I installed your reproducer and i did not reproduced the problem:

Enregistrement.de.l.ecran.2024-02-07.a.21.26.25.mov

Could this be a cache problem ?

@tijnema
Copy link
Author

tijnema commented Feb 7, 2024

I installed your reproducer and i did not reproduced the problem:

Enregistrement.de.l.ecran.2024-02-07.a.21.26.25.mov
Could this be a cache problem ?

Did you update to 2.14 (composer require symfony/ux-live-component="v2.14.0") ? The code as-is shows working situation with 2.13

@smnandre
Copy link
Collaborator

smnandre commented Feb 7, 2024

Enregistrement.de.l.ecran.2024-02-07.a.21.38.46.mov

@tijnema
Copy link
Author

tijnema commented Feb 7, 2024

I tried clearing cache, removing project and reinstalling from github, but I keep getting the same. I have no clue why it behaves normally on your machine.
Screencast_20240207_214931-2.webm

I installed it also on a dev server for anyone to test: http://livebug.tijnema.com

@smnandre
Copy link
Collaborator

smnandre commented Feb 7, 2024

It is probably related to major changes that occured in the morphin algorithm... as you remove a node in the same time you add one, it seems their is some confusion and the final result is .... surprising indeed.

The only short-term solution is see for you there is to help the morphing, wrapping your two components

(tested on my machine, but you know...)

  <div id="foo-a">
      {% if this.even %}
          {{ component('child_a') }}
      {% endif %}
  </div>
  <div id="foo-b">
      {% if not this.even %}
          {{ component('child_b') }}
      {% endif %}
  </div>

@weaverryan weaverryan added the Bug Bug Fix label Feb 8, 2024
@carsonbot carsonbot added the Status: Needs Review Needs to be reviewed label Feb 8, 2024
@weaverryan
Copy link
Member

@smnandre is correct about the morphing algorithm change. I can see the problem - I'm checking into it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Bug Fix Status: Needs Review Needs to be reviewed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants