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 LiveProp onUpdated option #2204

Open
jeremy-ritec opened this issue Sep 25, 2024 · 1 comment
Open

LiveComponent LiveProp onUpdated option #2204

jeremy-ritec opened this issue Sep 25, 2024 · 1 comment

Comments

@jeremy-ritec
Copy link

Consider this :

    #[LiveProp(writable: true, url: new UrlMapping(as: 's'), onUpdated: "onSubcategoryUpdated")]
    public array $courseSubcategory = [];

    #[LiveProp(writable: true, url: new UrlMapping(as: 'c'), onUpdated: "onCategoryUpdated")]
    public ?string $courseCategory = null;

    #[LiveProp(writable: true, onUpdated: "refresh")]
    public string $sort = 'relevance';

and the user already changed the $sort value ($sort is not "relevance" anymore) and so is the $courseSubcategory (not empty anymore). If I change the $courseCategory value, and the onCategoryUpdated() is triggered, the value of $sort becomes the initial one ie "relevance"; whereas $courseSubcategory keeps its current value.

And the bug persists not matter how the variable declarations order is. Variables declared above the triggered onUpdated function remember their current value, whereas those declared below use the initial ones.

@smnandre
Copy link
Member

smnandre commented Oct 5, 2024

Do you think maybe you could show a tiny bit more of code ? 😄

Like, what's in "onSubcategoryUpdated" and "onCategoryUpdated" methods ?

And eventually what you mean by "if i change [...]" ? (in PHP ? JS ? via a form ? the URL ?)

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants