Merge conflict Gerrit cannot merge this change. It needs a rebase onto main.
97165[FEATURE] Offer file and folder search options
Commit message
Test this change
Run a command in your clone of the TYPO3 Core. Then try what the change does and vote on Verified in Gerrit. How to review a patch
- Check out patch set 3
-
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/65/97165/3 && git checkout FETCH_HEAD - Cherry-pick onto main
-
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/65/97165/3 && git cherry-pick FETCH_HEAD
Review
-
Code review CR 0 Needs a vote
-
Verified V 0 Needs a vote
- core-ci +1 CI
Issues 1
Files 44
- Build/Sources/Sass/module/_filelist.scss+26 −0
- Build/Sources/TypeScript/backend/resource/file-search-options.tsnew+91 −0
- Build/Sources/TypeScript/backend/tests/resource/file-search-options-test.tsnew+93 −0
- Build/Sources/TypeScript/backend/tests/tree/file-storage-tree-toolbar-test.tsnew+78 −0
- Build/Sources/TypeScript/backend/tests/tree/tree-test.ts+63 −1
- Build/Sources/TypeScript/backend/tree/file-storage-browser.ts+7 −3
- Build/Sources/TypeScript/backend/tree/file-storage-tree-container.ts+14 −5
- Build/Sources/TypeScript/backend/tree/file-storage-tree-toolbar.tsnew+74 −0
- Build/Sources/TypeScript/backend/tree/file-storage-tree.ts+13 −0
- Build/Sources/TypeScript/backend/tree/page-tree-element.ts+2 −2
- Build/Sources/TypeScript/backend/tree/tree-toolbar.ts+9 −1
- Build/Sources/TypeScript/backend/tree/tree.ts+8 −9
- Build/Sources/TypeScript/filelist/file-list-search-options.tsnew+133 −0
- Build/tests/playwright/e2e/media/file-search-options.spec.tsnew+249 −0
- typo3/sysext/backend/Classes/Controller/FileStorage/TreeController.php+23 −2
- typo3/sysext/backend/Classes/Search/FileSearchOptions.phpnew+128 −0
- typo3/sysext/backend/Classes/Tree/FileStorageTreeProvider.php+16 −8
- typo3/sysext/backend/Configuration/Backend/AjaxRoutes.php+7 −0
- typo3/sysext/backend/Resources/Public/Css/backend.css+4 −0
- typo3/sysext/backend/Resources/Public/JavaScript/resource/file-search-options.jsnew+13 −0
Show 24 more files
- typo3/sysext/backend/Resources/Public/JavaScript/tree/file-storage-browser.js+1 −1
- typo3/sysext/backend/Resources/Public/JavaScript/tree/file-storage-tree-container.js+1 −1
- typo3/sysext/backend/Resources/Public/JavaScript/tree/file-storage-tree-toolbar.jsnew+13 −0
- typo3/sysext/backend/Resources/Public/JavaScript/tree/file-storage-tree.js+1 −1
- typo3/sysext/backend/Resources/Public/JavaScript/tree/page-tree-element.js+1 −1
- typo3/sysext/backend/Resources/Public/JavaScript/tree/tree-toolbar.js+1 −1
- typo3/sysext/backend/Resources/Public/JavaScript/tree/tree.js+1 −1
- typo3/sysext/backend/Tests/Functional/Controller/FileStorage/Fixtures/be_users.csv+2 −1
- typo3/sysext/backend/Tests/Functional/Controller/FileStorage/Fixtures/be_users_with_file_mount.csvnew+6 −0
- typo3/sysext/backend/Tests/Functional/Controller/FileStorage/TreeControllerTest.php+126 −0
- typo3/sysext/backend/Tests/Unit/Search/FileSearchOptionsTest.phpnew+172 −0
- typo3/sysext/core/Classes/Resource/Search/QueryRestrictions/SearchTermRestriction.php+78 −28
- typo3/sysext/core/Classes/Resource/Search/FileSearchDemand.php+26 −0
- typo3/sysext/core/Classes/Resource/Search/FileSearchScope.phpnew+41 −0
- typo3/sysext/core/Documentation/Changelog/15.0/Feature-111249-SearchOptionsForFolderTreeAndFileList.rstnew+103 −0
- typo3/sysext/core/Resources/Private/Language/locallang_core.xlf+18 −0
- typo3/sysext/core/Tests/Functional/Resource/Search/FileSearchQueryTest.php+193 −0
- typo3/sysext/filelist/Classes/Controller/FileListController.php+25 −1
- typo3/sysext/filelist/Classes/ElementBrowser/FileBrowser.php+2 −0
- typo3/sysext/filelist/Classes/LinkHandler/FileLinkHandler.php+2 −0
- typo3/sysext/filelist/Resources/Private/Templates/ElementBrowser/Files.fluid.html+1 −0
- typo3/sysext/filelist/Resources/Private/Templates/File/List.fluid.html+29 −1
- typo3/sysext/filelist/Resources/Private/Templates/LinkHandler/File.fluid.html+1 −0
- typo3/sysext/filelist/Resources/Public/JavaScript/file-list-search-options.jsnew+13 −0
Review log 710
-
Garvin Hicking uploaded patch set 1 10/26/26, 15:01
-
Garvin Hicking commented on patch set 1 10/26/26, 15:03
-
core-ci voted on patch set 1 V +1 10/26/26, 15:09 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/112597
-
Garvin Hicking commented on patch set 1 10/27/26, 13:48
Agentic code-review concerns; will strike back. 1: typo3/sysext/core/Classes/Resource/Search/QueryRestrictions/SearchTermRestriction.php:53: with all options enabled (the default), each scope now ANDs all term parts on its own field and the scopes are ORed. 2024 invoice no longer finds /2024/invoice-01.pdf, and the test case at FileSearchQueryTest.php:107 encodes this regression. Please keep the old combinator and restrict only the field set: AND over the term parts of (OR over the enabled scope expressions), and add tests for multi-word and folder+file terms with all scopes enabled.. 2: typo3/sysext/backend/Classes/Tree/FileStorageTreeProvider.php:207: "Search in folder names" now matches the full storage-relative identifier instead of the folder name, and it is on by default. Every descendant of a matching folder becomes a hit, and an editor with the mount /user_upload/team_a/ searching team gets the whole mount. This goes against the issue's goal of fewer unwanted results, so please match the folder name in the tree as before. If path matching is wanted for the file list, call it "folder path" and strip the mount prefix.. 3: Build/Sources/TypeScript/filelist/file-list-search-options.ts:80: the tree search and the file list search share one persisted state across frames. Toggling an option in the tree reloads the file list, and vice versa, and it needs a topDocument broadcast plus a TYPO3.settings entry on every backend load. Could you follow the page tree precedent (PageTreeToolbar::renderSearchOptions, Page\TreeController::fetchConfigurationAction) and keep the tree options local to the tree? Whether the file list needs options at all can be decided once the regressions are fixed.. 4: Build/Sources/TypeScript/backend/tree/file-storage-browser.ts:99: the folder pickers (ElementBrowser/Folder, ElementBrowser/ResourceCreation, LinkHandler/Folder) pass no search-options, so they now also search metadata and show folders because of file metadata, with no hint why. That wasn't requested and makes the pickers noisier and slower. Please leave metadata out of the tree and keep folder name search for the pickers.. 5: typo3/sysext/core/Classes/Resource/Search/QueryRestrictions/SearchTermRestriction.php:43: unticking all options (or setting all three TSconfig keys to 0) makes every search return nothing, persisted in uc and also applied in the element and link browsers, which show no options. Please don't allow unchecking the last option, as the page tree always searches the title, and fall back to all fields when TSconfig disables everything.. 6: typo3/sysext/core/Classes/Resource/Search/FileSearchDemand.php:154: the semantics of null, [] and all three scopes differ (null searches all TCA-searchable fields, [] finds nothing, and sys_file fields added via TCA or addSearchField() are ignored once scopes are set). FileSearchScope::FolderNames also matches paths. Once released this is public API, so please define the interaction with search fields explicitly and name the case after what it does, or keep the scope mechanism @internal until there is a second consumer.. 7: typo3/sysext/backend/Classes/Search/FileSearchOptions.php:56: the options.folderTree.searchIn* and folderTree_searchIn* keys also control the file list and the element/link browser searches. TSconfig keys are hard to rename later, so if the state stays shared please use a neutral namespace.. 8: Build/Sources/TypeScript/backend/resource/file-search-options.ts:69: each click writes all options one after another, and local state only updates after all awaits. A second click in between works from stale state and the last write wins. Please update local state immediately and persist only the toggled key with one Persistent.set.. 9: Build/tests/playwright/e2e/media/file-search-options.spec.ts:11: there are no tests for multi-word terms with all scopes, a non-admin with a file mount, or the folder pickers. The spec also changes the shared admin's uc and only restores it in the last step, so a failure leaves options disabled for later tests. Please add those cases and reset the user settings in afterEach.. 10: Build/Sources/TypeScript/backend/resource/file-search-options.ts:84 (optional): menuitemcheckbox items sit in a ul without role="menu", next to plain-button siblings. Please use a complete menu pattern, or plain buttons with aria-pressed like the page tree options.. 11: typo3/sysext/filelist/Resources/Private/Templates/File/List.fluid.html:72 (optional): the kebab icon is hard to discover and shows no state. A filter icon with an active marker when not all options are enabled would help.. 12: Build/Sources/TypeScript/backend/tree/tree-toolbar.ts:111 (optional): PageTreeToolbar keeps its own renderSearchOptions() while TreeToolbar gets a new hook, which creates two mechanisms for the same purpose. Please migrate PageTreeToolbar to the hook, or explain why not.. -
Garvin Hicking uploaded patch set 2
V +110/27/26, 18:12 -
Garvin Hicking commented on patch set 2 10/27/26, 18:15
Reply
What changed, per comment number from above: 1. Multi-word search: each word now has to match the file name or the folder path, so 2024 invoice finds /2024/invoice-01.pdf again. A term spanning both, like other/needle, also matches. Metadata is still matched separately, as before the patch. The reviewer's formula would also mix metadata into each word, which matches more than the old search did. Tests cover these cases. 2. Tree folder search: matches the folder name only again. The file list option is renamed "Search in folder paths" and only looks at the path below the current folder, so the mount prefix no longer matches. 3. Separate state: the tree loads its options from a new filestorage_tree_configuration route, like the page tree does. The cross-frame event, the TYPO3.settings entry and the BackendController change are gone. User settings are folderTree_* for the tree and fileList_* for the list. 4. Pickers: the tree has no metadata option any more. Folder pickers search file and folder names, as before the patch. 5. No empty search: the last enabled option can't be unticked. If TSconfig or saved settings leave nothing enabled, everything is searched. If only one option is left, no menu is shown. 6. Core API: FileSearchScope and withScopes() are marked @internal, the FolderNames case is renamed FolderPath, and an empty scope list now behaves like no scopes. The docblock spells out how scopes interact with addSearchField(). 7. TSconfig: the file list options moved to options.file_list.searchIn*. 8. Clicks in quick succession: local state updates immediately and only the toggled key is saved. Saves are queued, because two parallel Persistent.set calls can overwrite each other on the server. The file list re-submits its search only after the last save. 9. Tests: - Added functional tests for multi-word and folder-plus-file terms with all options on, for path matching below the searched folder, and for an editor with a file mount. - The editor case is a functional test, not e2e: the e2e suite only logs in as admin, and its editor user has no file mount. - The e2e spec covers the folder picker and resets the user settings in afterEach. 10. Accessibility: menu items are plain buttons with aria-pressed. 11. Filter icon: the file list toggle is now a filter icon with a badge that shows while an option is disabled. It shows a number of either "1" (only one filter applied) or "2" (two filters applied) or none (all filters applied -> the default, and no indicator needed that any customization applies). 12. One mechanism: PageTreeToolbar now uses the renderAdditionalMenuItems() hook. The class isn't exported, so nothing breaks. Bonus drive-by: The file list tree did not change if searching for a term that yielded no results, unlike the regular page tree (which folded into the main node). Now the tree also folds, and shows no results to indicate the search failed. Clearing the term also resets the tree again. -
core-ci voted on patch set 2 V +1 10/27/26, 18:19 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/112653
-
Garvin Hicking uploaded patch set 3
V +110/27/26, 18:43self self review service -
Garvin Hicking commented on patch set 3 10/27/26, 18:44
Reply Unresolved
Claude Self-review of this patch set, with the claude findings claude fixed in it reclausively: Fixed - File search on SQLite: the LIKE comparisons of SearchTermRestriction had no ESCAPE clause. SQLite has no default escape character, so the escaped folder identifier (e.g. /user\_upload/) never matched and "Search in folder paths" found nothing below folders containing "_". The comparisons now state the escape character, which also makes "_" and "%" in search terms match literally on SQLite. Covered by FileSearchQueryTest::underscoresInFolderIdentifiersAndSearchTermsAreMatched, run on SQLite, MariaDB, MySQL and PostgreSQL. - Folder tree options shown vs. searched: the navigation tree loaded its options once, while filterData read the user preferences on every request. Changing the options in the tree of a file or link browser changed the search of the navigation tree without updating its menu. Each tree now hands over the options it shows ("searchIn"), the server only checks them against TSconfig. User preferences only provide the initial state. This replaces the "applySearchOptions=0" flag: trees without options send nothing and search in all options available to the user. Toggling an option filters again right away instead of waiting for the preference to be stored. - Tree filter reset: resetFilter() kept the stored unfiltered nodes when it reloaded the tree instead of restoring them (no selected node, which is always the case after a search without matches). The next search then kept the outdated copy, and resetting it restored a tree without folders created meanwhile. The copy is now dropped on reload. - Changelog: folder selectors search in all options available to the user, TSconfig still applies to them. - FileLinkHandler: removed a LinkType::FOLDER check that never matches, folders are linked by FolderLinkHandler. Kept on purpose - The filter toggle and its badge are rendered by Fluid as a direct child of .input-group, as the input group styles (borders, radius, stacking) address direct children. The component updates the badge. - The z-index rules of the toggle (with !important against .btn:hover) keep the badge above the search button and the toggle below a focused search field. - The file list menu keeps itself open against @typo3/backend/dropdown, which closes menus on item clicks and on focusout. The focusout reopening a menu when clicking its toggle is a core bug of its own, to be fixed in a separate change. - The folder tree menu closes after each toggle, like the search options of the page tree, and filters right away. - The folder tree matches the search term as a whole, like before; the word-wise matching applies to the file list search only. - Closing the file list menu repeats a search that is shown, it does not start one for a term typed but not submitted. - A tree search without matches shows an empty tree without a message, like the page tree for editors. Tests run - Unit: backend + core Resource (1723 tests), JS unit tests (382) - Functional: FileStorage TreeController, Resource Search (all 4 DBMS), filelist - E2E: media/file-search-options, media/file-search, page-tree/page-tree-filter, page-tree/page-tree-filter-selection - PHPStan (changed files), CGL, lintTypescript, lintScss, checkRst, checkIntegrityXliff -
core-ci voted on patch set 3 V +1 10/27/26, 18:51 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/112654
Unresolved