laravel / nova-issues

556 stars 34 forks source link

MenuSection Component is Hard-Coded in Serialization #5922

Closed tylernathanreed closed 1 year ago

tylernathanreed commented 1 year ago

Description:

When creating a child class of the MenuSection class, overriding the $component property is not sufficient to change the component attribute in the JSON payload, as the jsonSerialize method has it hard-coded.

From MenuSection:

/**
 * Prepare the menu for JSON serialization.
 *
 * @return array<string, mixed>
 */
public function jsonSerialize(): array
{
    /* ... */

    return [
        /* ... */
        'component' => 'menu-section',
        /* ... */
    ];
}

The code should be using $this->component instead:

public function jsonSerialize(): array
{
    /* ... */

    return [
        /* ... */
        'component' => $this->component,
        /* ... */
    ];
}
davidhemphill commented 1 year ago

This has been fixed and will be included in the next release. 👍