-
-
Notifications
You must be signed in to change notification settings - Fork 403
Description
Hi. I'm not able to present a minimal reproducer, but we have a problem with an anonymous component rendering.
The problem is happening only for the event handling render (\Symfony\UX\LiveComponent\Attribute\PreReRender -> \Symfony\UX\LiveComponent\ComponentToolsTrait::emit -> POST https://redacted/en/_components/sylius_shop:product:summary/eventNameRedacted)
I have reviewed the code and I see an issue with the anonymous components metadata handling.
\Symfony\UX\LiveComponent\Metadata\LiveComponentMetadataFactory::getMetadata:
public function getMetadata(string $name): LiveComponentMetadata
{
// some not related code removed
$componentMetadata = $this->componentFactory->metadataFor($name);
// here the getClass() is called:
$reflectionClass = new \ReflectionClass($componentMetadata->getClass());
// some not related code removed
}
\Symfony\UX\TwigComponent\ComponentFactory::metadataFor:
public function metadataFor(string $name): ComponentMetadata
{
// some not related code removed
if ($template = $this->componentTemplateFinder->findAnonymousComponentTemplate($name)) {
$this->config[$name] = [
'key' => $name,
'template' => $template,
];
// here we return the metadata with only two keys in the config (key, template):
return new ComponentMetadata($this->config[$name]);
}
As you can see, it tries to read "class", but there is no class defined for the anonymous components. There are only key and template defined for them. I believe the code is missing for the AnonymousComponent special case handling.
We use the latest versions of symfony/ux-live-component symfony/ux-twig-component libs.