Project

General

Profile

Actions

Bug #103174

closed

CustomFileControlsEvent does not support javaScriptModules

Added by Daniel Siepmann 2 months ago. Updated 2 months ago.

Status:
Resolved
Priority:
Should have
Assignee:
-
Category:
Backend JavaScript
Target version:
-
Start date:
2024-02-22
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
12
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

The event provides access to the `$resultArray` and allows to set a new version of that variable.
But the triggering code does not use the modified version.

That array holds a list of javaScriptModules to load. This info is not respected.

This worked prior the event when one used a UserFunction in order to add custom controls, as the resultArray was provided and could be handled as reference.

It seems I could fix this via:

diff --git a/typo3/sysext/backend/Classes/Form/Container/FilesControlContainer.php b/typo3/sysext/backend/Classes/Form/Container/FilesControlContainer.php
index c231c8d076..250e1b7e68 100644
--- a/typo3/sysext/backend/Classes/Form/Container/FilesControlContainer.php
+++ b/typo3/sysext/backend/Classes/Form/Container/FilesControlContainer.php
@@ -271,14 +271,15 @@ class FilesControlContainer extends AbstractContainer
             }
         }

-        $controls = $this->eventDispatcher->dispatch(
+        $event = GeneralUtility::makeInstance(EventDispatcherInterface::class)->dispatch(
             new CustomFileControlsEvent($resultArray, $table, $field, $row, $config, $formFieldIdentifier, $formFieldName)
-        )->getControls();
+        );
+        $resultArray = $event->getResultArray();

-        if ($controls !== []) {
+        if ($event->getControls() !== []) {
             $view->assign('customControls', [
                 'id' => $formFieldIdentifier . '_customControls',
-                'controls' => implode("\n", $controls),
+                'controls' => implode("\n", $event->getControls()),
             ]);
         }

But then I end up with

Uncaught (in promise) Error: Unable to resolve specifier '@e2/e2-core/FilePathBasedBrowser/SearchForm.js' imported from http://localhost:8080/typo3/record/edit?token=a91f1f57ee42b3

I expect https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/12.0/Breaking-98479-RemovedFileReferenceRelatedFunctionality.html to be the change that broke the feature.

Actions #1

Updated by Daniel Siepmann 2 months ago

  • Description updated (diff)
Actions #2

Updated by Daniel Siepmann 2 months ago

  • Description updated (diff)
Actions #3

Updated by Gerrit Code Review 2 months ago

  • Status changed from New to Under Review

Patch set 1 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/83072

Actions #4

Updated by Benjamin Franzke 2 months ago · Edited

Thanks, I pushed a patch.

But then I end up with

Uncaught (in promise) Error: Unable to resolve specifier '@e2/e2-core/FilePathBasedBrowser/SearchForm.js' imported from http://localhost:8080/typo3/record/edit?token=a91f1f57ee42b3

You need to define 'tags' => [ 'backend.form' ] in Configuration/JavaScriptModules.php. Please test with that.
(Reason is that your JavaScript module is loaded as a result of a fetch-request, but the importmap needs to be prefilled with your imports in order for that to work – we can't alter the importmap at runtime, therefore we introduced tags)

Actions #5

Updated by Daniel Siepmann 2 months ago

Thanks Benjamin, that solves my issue.

Actions #6

Updated by Gerrit Code Review 2 months ago

Patch set 2 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/83072

Actions #7

Updated by Gerrit Code Review 2 months ago

Patch set 3 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/83072

Actions #8

Updated by Gerrit Code Review 2 months ago

Patch set 1 for branch 12.4 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/83081

Actions #9

Updated by Gerrit Code Review 2 months ago

Patch set 2 for branch 12.4 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/83081

Actions #10

Updated by Gerrit Code Review 2 months ago

Patch set 3 for branch 12.4 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/83081

Actions #11

Updated by Anonymous 2 months ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions

Also available in: Atom PDF