Skip to content

[LiveComponents] Child component cannot read URL parameters if the parent component is defered #2690

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

Open
momocode-de opened this issue Apr 11, 2025 · 0 comments
Labels
Bug Bug Fix Status: Needs Review Needs to be reviewed

Comments

@momocode-de
Copy link

I have noticed that if I have nested components and the parent component is included with loading: 'defer', the child component can no longer read URL parameters. Here is my code:

Parent Component

<?php

namespace App\Twig\Components;

use Symfony\UX\LiveComponent\Attribute\AsLiveComponent;
use Symfony\UX\LiveComponent\DefaultActionTrait;

#[AsLiveComponent]
class ParentComponent
{
    use DefaultActionTrait;
}
<div {{ attributes }}>
        <h1>Parent Component</h1>

        {{ component('ChildComponent', {
                sort: 'name'
        }) }}
</div>

Child Component

<?php

namespace App\Twig\Components;

use Symfony\UX\LiveComponent\Attribute\AsLiveComponent;
use Symfony\UX\LiveComponent\Attribute\LiveProp;
use Symfony\UX\LiveComponent\DefaultActionTrait;

#[AsLiveComponent]
class ChildComponent
{
    use DefaultActionTrait;

    #[LiveProp(writable: true, url: true)]
    public string $sort = '';
}
<div {{ attributes }}>
        <h1>Child Component</h1>

        {{ dump(sort) }}
</div>

Main template:

{{ component('ParentComponent', { loading: 'defer' }) }}

If I now call up my page with ?sort=foo, the value “name” is dumped instead of “foo”. If I remove the { loading: 'defer' } from the parent component, the value “foo” is dumped. Is it possible in this scenario that the parent component remains defered and the child component can still read the URL parameters?

@momocode-de momocode-de added the Bug Bug Fix label Apr 11, 2025
@carsonbot carsonbot added the Status: Needs Review Needs to be reviewed label Apr 11, 2025
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

No branches or pull requests

2 participants