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

[StimulusBundle] Lazy controllers not loaded with Turbo #2576

Open
BackNot opened this issue Feb 17, 2025 · 5 comments · May be fixed by #2590
Open

[StimulusBundle] Lazy controllers not loaded with Turbo #2576

BackNot opened this issue Feb 17, 2025 · 5 comments · May be fixed by #2590
Labels
Bug Bug Fix Status: Reviewed Has been reviewed by a maintainer StimulusBundle

Comments

@BackNot
Copy link

BackNot commented Feb 17, 2025

I am using Turbo and Stimulus. After the upgrade to v2.23.0 my lazy loaded controllers are not loaded sometimes. If I navigate in my app via Turbo drive my lazy loaded controllers are sometimes not loaded. If I perform full page refresh they are loaded. If I remove the lazy load they are loaded as well. See my 2 screenshots. One is navigated with Turbo Drive the other is with full page refresh. I have "click" controller that is connected to the elements on my page.

  <br>
    <br>  <br>  <br>
    <div class="w-1/2" data-controller="click">
        <div data-click-target="title">Not clicked yet</div>
        <input type="submit" data-click-target="button" data-action="click->click#clicked" class="btn btn-sm bg-accent">
    </div>
/* stimulusFetch: 'lazy' */
export default class extends Controller {
    static targets = ["button", "title"]

    clicked() {
        this.titleTarget.innerHTML = "Clicked";
    }
}
Image Image
@BackNot BackNot added the Bug Bug Fix label Feb 17, 2025
@carsonbot carsonbot added the Status: Needs Review Needs to be reviewed label Feb 17, 2025
@clussiana
Copy link
Contributor

clussiana commented Feb 20, 2025

Hi, I'm facing the same issue, it might be related to the changes here symfony/stimulus-bundle@v2.22.1...v2.23.0 @Kocal

@smnandre
Copy link
Member

Do you guys think you'd be able to set a small reproducer with the minimal amount of code, for investigation ?

@adr1enbe4udou1n
Copy link

Same bug related to this PR symfony/stimulus-bundle@254f4e0

For reproduction just upgrade inside ux.symfony.com project to symfony/[email protected], then navigate between https://ux.symfony.com/turbo and https://ux.symfony.com/live-component pages

The 2 following controllers should be lazy loaded, but it's not with this last version :

Image

@smnandre
Copy link
Member

Ok thank you!

I will try to fix this during the week-end ... or will revert.

If someone want to have a look before, please do :)

@smnandre smnandre added Status: Reviewed Has been reviewed by a maintainer StimulusBundle and removed Status: Needs Review Needs to be reviewed labels Feb 21, 2025
@smnandre smnandre changed the title Stimulus lazy loaded controllers are not always loaded [StimulusBundle] Lazy controllers not loaded with Turbo Feb 21, 2025
@smnandre smnandre linked a pull request Feb 22, 2025 that will close this issue
@smnandre
Copy link
Member

I opened a PRI... could you please guys check it and tell me how it goes for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Bug Fix Status: Reviewed Has been reviewed by a maintainer StimulusBundle
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants