EasyAdminBundle icon indicating copy to clipboard operation
EasyAdminBundle copied to clipboard

[BUG] Action Button without label

Open MIvanIsten opened this issue 1 month ago • 2 comments

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>

MIvanIsten avatar Nov 02 '25 15:11 MIvanIsten

Same as #7117

ThibautM21 avatar Nov 02 '25 19:11 ThibautM21

Confirmed, easy fix for now:

.datagrid td.actions:not(.actions-as-dropdown) {
  .btn-icon + .btn-label:empty {
    display: none;
  }
}

gremo avatar Nov 04 '25 22:11 gremo

@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?

gremo avatar Dec 12 '25 08:12 gremo