Issue Bug Under Review Quiet Regression

#108711IsFileSelectableEvent hides files instead of disabling selection and lacks click-prevention

HOJA M A 01/21/26, 10:53 updated 10/30/26, 22:34

Description

A regression has been introduced in TYPO3 v13 following commit 000057083adb17c641939dd18ebfc97a0a98ae08.
The current implementation of IsFileSelectableEvent against the resourceDisplayMatcher incorrectly hides files from the view entirely when they are marked as non-selectable. Furthermore, even when a file is marked as non-selectable, the primary click action (selecting by filename/thumbnail) remains active, allowing users to bypass the restriction. Which replaces the fixes from https://review.typo3.org/c/Packages/TYPO3.CMS/+/89069

*Background*
In previous iterations, IsFileSelectableEvent intended to allow developers to define whether a file could be picked/selected (e.g., within a FileBrowser or a selection list).
The referenced commit moved this logic to the resourceDisplayMatcher. In TYPO3’s Core logic, if a display matcher returns false, the resource is not rendered at all. This conflates “Ability to see a file” with “Ability to select a file.”

Current Issues

Issue 1: Improper Use of resourceDisplayMatcher
Because the event is now dispatched within the resourceDisplayMatcher context:

Expected Behavior: If a file is not “selectable,” the checkbox should be disabled or hidden, but the file should remain visible in the list for context.

Actual Behavior: The file is completely removed from the DOM/view. Users cannot see files that exist simply because they aren’t selectable at that specific moment.

Issue 2: Primary Action Bypass (The “v12 Legacy Bug”)
When a file is marked as non-selectable (and if the display logic is bypassed to show the file), the checkbox disappears, but the file remains interactable:
The HTML attribute data-filelist-action=“primary” remains active on the file title or tile.
A user can still click the file name/thumbnail to select it, even though the checkbox is gone.

Result: The IsFileSelectableEvent is effectively bypassed by a simple mouse click on the label.

*Proposed Solution*
To restore the intended functionality and ensure a robust UI, the following changes are needed:

Logic Separation: Move the IsFileSelectableEvent check from the resourceDisplayMatcher back to resourceSelectableMatcher.

*Template Enforcement (Tile & List View):*
In the Tile view, if isFileSelectable is false, the disabled attribute must be applied to the wrapping element to prevent click events.
In the List view, the logic inside the FileList controller/component must ensure that the primary action is not assigned to the filename if the event listener has marked the file as non-selectable.

UI Consistency: Ensure that a non-selectable file is visually dimmed (standard CSS disabled state) rather than being removed from the UI entirely.

*Steps to Reproduce*
Implement an Event Listener for IsFileSelectableEvent.
Set $event->setIsFileSelectable(false) for a specific file.
Open the FileList or FileBrowser in TYPO3 v13.
Observe: The file disappears entirely (Issue 1).
(If forced to display) Observe: Clicking the file name still triggers the selection/primary action (Issue 2).

*Expected Behaviour*
clipboard-202601211143-swtm3.png

Reviews 3

Files 1

History 418

  1. Josef Glatz changed subject [BUG] Regression: IsFileSelectableEvent hides files instead of disabling selection and lacks click-prevention IsFileSelectableEvent hides files instead of disabling selection and lacks click-prevention Is Regression 0 1 <span data-processor="relativetime" data-value="2026-01-21T11:33:42+00:00" > 01/21/26, 11:33 </span>

  2. Stefan Froemken commented <span data-processor="relativetime" data-value="2026-05-19T13:55:23+00:00" > 05/19/26, 13:55 </span>

    A simplyfied EventListener for testing:

    <?php
    
    declare(strict_types=1);
    
    namespace StefanFroemken\SitePackage\EventListener;
    
    use TYPO3\CMS\Backend\ElementBrowser\Event\IsFileSelectableEvent;
    use TYPO3\CMS\Core\Attribute\AsEventListener;
    use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
    use TYPO3\CMS\Core\Database\ConnectionPool;
    use TYPO3\CMS\Core\Messaging\FlashMessage;
    use TYPO3\CMS\Core\Messaging\FlashMessageQueue;
    use TYPO3\CMS\Core\Messaging\FlashMessageService;
    use TYPO3\CMS\Core\Resource\File;
    use TYPO3\CMS\Core\Type\ContextualFeedbackSeverity;
    use TYPO3\CMS\Core\Utility\GeneralUtility;
    
    #[AsEventListener(
        identifier: 'site-package/is-file-selectable',
    )]
    final readonly class IsFileSelectableEventListener
    {
        protected const REQUIRED_COLUMNS = ['creator', 'copyright'];
    
        public function __construct(
            protected ExtensionConfiguration $extensionConfiguration,
            protected FlashMessageService $flashMessageService,
            protected ConnectionPool $connectionPool,
        ) {}
    
        public function __invoke(IsFileSelectableEvent $event): void
        {
            $flashMessageQueue = $this->flashMessageService->getMessageQueueByIdentifier();
            $message = 'Creator and Copyright are mandatory columns and must therefor be filled';
    
            if (!$this->checkMessageExists($flashMessageQueue, $message)) {
                $this->addFlashMessage($flashMessageQueue, $message);
            }
    
            if (!$event->getFile() instanceof File) {
                // Do not process folders or processed files
                return;
            }
    
            if ($event->getFile()->getType() !== 2) {
                // Process only images
                return;
            }
    
            foreach (self::REQUIRED_COLUMNS as $requiredColumn) {
                $properties = $event->getFile()->getProperties();
    
                // Do not use isset() as "null" values have to be tested, too.
                if (!array_key_exists($requiredColumn, $properties)) {
                    $event->denyFileSelection();
                    return;
                }
    
                $mixedDbValue = is_string($properties[$requiredColumn])
                    ? trim($properties[$requiredColumn])
                    : $properties[$requiredColumn];
    
                if (empty($mixedDbValue)) {
                    $event->denyFileSelection();
                    return;
                }
            }
        }
    
        protected function addFlashMessage(FlashMessageQueue $flashMessageQueue, string $message): void
        {
            $flashMessageQueue->addMessage(
                GeneralUtility::makeInstance(
                    FlashMessage::class,
                    $message,
                    'Mandatory columns need to be filled',
                    ContextualFeedbackSeverity::INFO,
                ),
            );
        }
    
        protected function checkMessageExists(FlashMessageQueue $flashMessageQueue, string $message): bool
        {
            $messageExists = false;
            foreach ($flashMessageQueue as $flashMessage) {
                if ($flashMessage->getMessage() === $message) {
                    $messageExists = true;
                    break;
                }
            }
    
            return $messageExists;
        }
    }
  3. Garvin Hicking commented and changed status Under Review Closed <span data-processor="relativetime" data-value="2026-10-02T12:28:09+00:00" > 10/02/26, 12:28 </span>

    Closing, see patch review in gerrit, couldn’t move this forward.

  4. Gerrit Code Review pushed patch set 1 for main to change 97246 status Closed Under Review <span data-processor="relativetime" data-value="2026-10-30T22:13:32+00:00" > 10/30/26, 22:13 </span>