Skip to content

[BUG] Action Button without label #7200

@MIvanIsten

Description

@MIvanIsten

Describe the bug
With the new Button component action buttons without label rendered wrong.

To Reproduce

    public function configureActions(Actions $actions): Actions
    {
        $testAction = Action::new('test')
            ->linkToUrl('#')
            ->setIcon('text-dark fa-fw fa-solid fa-bug')
            ->setLabel(false);
        return $actions
            ->add(Crud::PAGE_INDEX, $testAction);
    }

results:

Image
<a class="btn btn-secondary  action-test" href="#" role="button" data-action-name="test" title="test">
    <span class="icon btn-icon">
        <i class="text-dark fa-fw fa-solid fa-bug"></i>
    </span>
    <span class="btn-label"></span>
</a>

an extra <span class="btn-label"></span> here

(OPTIONAL) Additional context
in crud/action.html.twig

{%- if outerScope.action.label is not empty -%}<span class="action-label">{{ outerScope.action.label|trans|raw }}</span>{%- endif -%}

does not render an extra <span class="action-label"></span> but makes content defined for Button component, so {% if block('content') is defined %} evaluates to true and renders the extra empty <span class="btn-label"></span>

changing {% if block('content') is defined %} to {% if block('content') is defined and block('content') is not empty %} does fix the rendering

Image
<a class="btn btn-secondary  action-test" href="#" role="button" data-action-name="test" title="test">
    <span class="icon btn-icon">
        <i class="text-dark fa-fw fa-solid fa-bug"></i>
    </span>
</a>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions