Skip to content

Commit

Permalink
[BUGFIX] Correct usage of GenericButton
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
benjaminkott authored and bnf committed Sep 6, 2023
1 parent 2797465 commit a541952
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Expand Up @@ -139,7 +139,7 @@ public function setShowLabelText(bool $showLabelText): self

public function isValid(): bool
{
return !empty($this->getLabel())
return trim($this->getLabel()) !== ''
&& $this->getType() === self::class
&& $this->getIcon() !== null;
}
Expand Down
10 changes: 5 additions & 5 deletions typo3/sysext/filelist/Classes/FileList.php
Expand Up @@ -991,7 +991,7 @@ protected function createControlView(ResourceView $resourceView): ?ButtonInterfa

$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));
Expand Down Expand Up @@ -1020,7 +1020,7 @@ protected function createControlRename(ResourceView $resourceView): ?ButtonInter
}

$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));

Expand All @@ -1038,7 +1038,7 @@ protected function createControlDownload(ResourceView $resourceView): ?ButtonInt
}

$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',
Expand Down Expand Up @@ -1072,7 +1072,7 @@ protected function createControlInfo(ResourceView $resourceView): ?ButtonInterfa
}

$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',
Expand Down Expand Up @@ -1107,7 +1107,7 @@ protected function createControlDelete(ResourceView $resourceView): ?ButtonInter

$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',
Expand Down

0 comments on commit a541952

Please sign in to comment.