From a541952684289de56bffc92299671a0785456e83 Mon Sep 17 00:00:00 2001
From: Benjamin Kott <benjamin.kott@outlook.com>
Date: Wed, 6 Sep 2023 09:55:57 +0200
Subject: [PATCH] [BUGFIX] Correct usage of GenericButton

The GenericButton requires a label to be set
instead of a title. The title rendering falls back
to the label if no dedicated title is provided.

Resolves: #101853
Releases: main, 12.4
Change-Id: I41e835b44ee2bf1b33927811b8353f49ad725b42
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/80878
Reviewed-by: Benjamin Franzke <ben@bnf.dev>
Tested-by: core-ci <typo3@b13.com>
Tested-by: Benjamin Franzke <ben@bnf.dev>
---
 .../Template/Components/Buttons/GenericButton.php      |  2 +-
 typo3/sysext/filelist/Classes/FileList.php             | 10 +++++-----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/typo3/sysext/backend/Classes/Template/Components/Buttons/GenericButton.php b/typo3/sysext/backend/Classes/Template/Components/Buttons/GenericButton.php
index c924eaa12cfc..c1b38ad24a9b 100644
--- a/typo3/sysext/backend/Classes/Template/Components/Buttons/GenericButton.php
+++ b/typo3/sysext/backend/Classes/Template/Components/Buttons/GenericButton.php
@@ -139,7 +139,7 @@ class GenericButton implements ButtonInterface
 
     public function isValid(): bool
     {
-        return !empty($this->getLabel())
+        return trim($this->getLabel()) !== ''
             && $this->getType() === self::class
             && $this->getIcon() !== null;
     }
diff --git a/typo3/sysext/filelist/Classes/FileList.php b/typo3/sysext/filelist/Classes/FileList.php
index 5684a4bd9f88..b136ce71aaa6 100644
--- a/typo3/sysext/filelist/Classes/FileList.php
+++ b/typo3/sysext/filelist/Classes/FileList.php
@@ -991,7 +991,7 @@ class FileList
 
         $button = GeneralUtility::makeInstance(GenericButton::class);
         $button->setTag('a');
-        $button->setTitle($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:cm.view'));
+        $button->setLabel($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:cm.view'));
         $button->setHref($resourceView->getPublicUrl());
         $button->setAttributes(['target' => '_blank']);
         $button->setIcon($this->iconFactory->getIcon('actions-document-view', Icon::SIZE_SMALL));
@@ -1020,7 +1020,7 @@ class FileList
         }
 
         $button = GeneralUtility::makeInstance(GenericButton::class);
-        $button->setTitle($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:cm.rename'));
+        $button->setLabel($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:cm.rename'));
         $button->setAttributes(['type' => 'button', 'data-filelist-action' => 'rename']);
         $button->setIcon($this->iconFactory->getIcon('actions-edit-rename', Icon::SIZE_SMALL));
 
@@ -1038,7 +1038,7 @@ class FileList
         }
 
         $button = GeneralUtility::makeInstance(GenericButton::class);
-        $button->setTitle($this->getLanguageService()->sL('LLL:EXT:filelist/Resources/Private/Language/locallang.xlf:download'));
+        $button->setLabel($this->getLanguageService()->sL('LLL:EXT:filelist/Resources/Private/Language/locallang.xlf:download'));
         $button->setAttributes([
             'type' => 'button',
             'data-filelist-action' => 'download',
@@ -1072,7 +1072,7 @@ class FileList
         }
 
         $button = GeneralUtility::makeInstance(GenericButton::class);
-        $button->setTitle($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:cm.info'));
+        $button->setLabel($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:cm.info'));
         $button->setAttributes([
             'type' => 'button',
             'data-filelist-action' => 'show',
@@ -1107,7 +1107,7 @@ class FileList
 
         $title = $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:cm.delete');
         $button = GeneralUtility::makeInstance(GenericButton::class);
-        $button->setTitle($title);
+        $button->setLabel($title);
         $button->setIcon($this->iconFactory->getIcon('actions-edit-delete', Icon::SIZE_SMALL));
         $button->setAttributes([
             'type' => 'button',
-- 
GitLab