Skip to content

LiveComponent LiveProp onUpdated option #2204

Open
@jeremy-ritec

Description

@jeremy-ritec

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions