Skip to content

Commit 950b6c8

Browse files
committed
bug #6872 fix: Do not override HTML attribute title if already set for Action… (jbonnier)
This PR was merged into the 4.x branch. Discussion ---------- fix: Do not override HTML attribute `title` if already set for Action… If an action has no label but has the HTML attribute already set, it should not be replaced by the action name. Use case example: ```php $moveDown = Action::new('moveDown', false, 'fa fa-angle-down') ->setHtmlAttributes(['title' => $this->trans('Move Down')]) ->linkToCrudAction('moveDown') ->displayIf(static fn(SortableEntityInterface $entity): bool => $entity->getPosition() < $entityCount - 1) ; ``` Commits ------- 4dd8bae fix: Do not override HTML attribute `title` if already set for Actions without a label
2 parents 78d24a4 + 4dd8bae commit 950b6c8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/Factory/ActionFactory.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,10 @@ private function processAction(string $pageName, ActionDto $actionDto, ?EntityDt
157157
private function processActionLabel(ActionDto $actionDto, ?EntityDto $entityDto, string $translationDomain, array $defaultTranslationParameters): void
158158
{
159159
$label = $actionDto->getLabel();
160+
$title = $actionDto->getHtmlAttributes()['title'] ?? '';
160161

161162
// FALSE means that action doesn't show a visible label in the interface
162-
if (false === $label) {
163+
if (false === $label && '' === trim($title)) {
163164
$actionDto->setHtmlAttribute('title', $actionDto->getName());
164165

165166
return;

0 commit comments

Comments
 (0)