Skip to content

[LiveComponents] Component HTML contains 11 elements, but only 1 root element is allowed, only when using nested components. #2312

Closed
@gremo

Description

@gremo

My PayrollSummary component is essentially an HTML table with rows populated from a database. There are 900 or more rows without any filters applied.

Long story short, I have a row cell with buttons:

<td>
    <twig:Button
        size="xs"
        theme="ghost"
    >
        <twig:ux:icon name="mdi:wand" class="size-4" />
    </twig:Button>

    <twig:Button> <!-- this is causing the error -->
        <twig:ux:icon name="mdi:edit" class="size-4" />
    </twig:Button>
</td>

This Twig excerpt will cause the following error:

Component HTML contains 11 elements, but only 1 root element is allowed, only when using nested components.

As soon as I change the second button to a simple HTML markup without a component, the problem disappear:

<button class="btn btn-xs btn-ghost">
    <twig:ux:icon name="mdi:edit" class="size-4" />
</button>

I've stripped all the props and attributes from my Button component to debug this error. I ended up with:

<button>
    {% block content %}{% endblock %}
</button>

Still getting the error. Any Idea?

EDIT: adding a random id doens't help:

<twig:Button
    id="payroll-{{ random() }}-justificatives-button"
    size="xs"
    theme="ghost"
    onclick="payroll_{{ payroll.id }}_justificatives.showModal()"
>
    <twig:ux:icon name="mdi:wand" class="size-4" />
</twig:Button>

<twig:Button
    id="payroll-{{ random() }}-edit-button"
    size="xs"
    theme="ghost"
>
    <twig:ux:icon name="mdi:edit" class="size-4" />
</twig:Button>

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions