[BUG] Action Button without label
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:
<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
<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>
Same as #7117
Confirmed, easy fix for now:
.datagrid td.actions:not(.actions-as-dropdown) {
.btn-icon + .btn-label:empty {
display: none;
}
}
@javiereguiluz i think that we already fixed it via CSS https://github.com/EasyCorp/EasyAdminBundle/pull/7247 so maybe as this is fixed now via Twig, should remove the CSS rule?