Skip to content

Media Picker: Allow folder selection in media entity picker (closes #21885)#21895

Merged
leekelleher merged 6 commits intomainfrom
v17/bugfix/handle-file-and-folder-options-in-media-picker
Mar 3, 2026
Merged

Media Picker: Allow folder selection in media entity picker (closes #21885)#21895
leekelleher merged 6 commits intomainfrom
v17/bugfix/handle-file-and-folder-options-in-media-picker

Conversation

@AndyButland
Copy link
Copy Markdown
Contributor

@AndyButland AndyButland commented Feb 24, 2026

Description

This PR addresses #21885 which shows a regression coming from #21678, which added an folder exclusion to the shared #pickableFilter in UmbMediaPickerInputContext. This correctly prevented folder selection in the link picker which was the intention, but also caused this problem, where folders are the intended selection target.

To resolve I've introduced a UmbMediaPickerFolderFilter enum (FILES_ONLY, FOLDERS_ONLY, FILES_AND_FOLDERS) to make folder selectability configurable per media picker instance.

This is passed through umb-input-media element and its picker context, defaulting to FILES_ONLY (preserving existing behaviour).

But we set FOLDERS_ONLY on the MediaEntityPicker so RTE "Image Upload Folder" and Media Picker "Start node" configs can select folders again.

Test plan

To manually test, create a media folder and some files in the Media section, then verify the following:

  • Go to a Rich Text Editor data type configuration → click "Choose" for "Image Upload Folder" → verify folders are selectable and files are NOT
  • Go to a Media Picker data type configuration → verify "Start node" folder selection works
  • Open a Multi URL Picker → link to media → verify folders are still NOT selectable (regression check)
  • Try to set media start nodes for a user or user group → verify folders only are selectable

Copilot AI review requested due to automatic review settings February 24, 2026 17:01
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds configurable folder selectability to the shared media picker input/context so folder selection can be enabled for the Media Entity Picker (used by RTE “Image Upload Folder” and Media Picker “Start node”) while preserving the existing “files only” behavior elsewhere (e.g., link-to-media scenarios).

Changes:

  • Introduces UmbMediaPickerFolderFilter and applies it in UmbMediaPickerInputContext’s pickableFilter.
  • Adds a folderFilter property/attribute to <umb-input-media> and forwards it into the picker context.
  • Sets folderFilter to FOLDERS_ONLY in the Media Entity Picker property editor.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/Umbraco.Web.UI.Client/src/packages/media/media/property-editors/media-entity-picker/property-editor-ui-media-entity-picker.element.ts Forces folder-only selection mode for the Media Entity Picker by setting folderFilter.
src/Umbraco.Web.UI.Client/src/packages/media/media/components/input-media/input-media.element.ts Adds folderFilter API on the element and forwards it when opening the picker.
src/Umbraco.Web.UI.Client/src/packages/media/media/components/input-media/input-media.context.ts Implements folder filtering logic inside the shared media picker pickableFilter.
Comments suppressed due to low confidence (2)

src/Umbraco.Web.UI.Client/src/packages/media/media/components/input-media/input-media.context.ts:91

  • The allowedContentTypes check is still applied after the folder filter. If folderFilter is set to FOLDERS_ONLY or FILES_AND_FOLDERS and allowedContentTypes is provided (common when restricting media types), folders will almost always be rejected because the folder media type isn’t included in allowedContentTypes. Consider applying allowedContentTypes filtering only to non-folder items (or otherwise exempting folders) so the new folder filter modes behave as expected.
		const isFolder = isUmbracoFolder(item.mediaType.unique);

		// Apply folder filter
		if (folderFilter === UmbMediaPickerFolderFilter.FILES_ONLY && isFolder) {
			return false;
		}
		if (folderFilter === UmbMediaPickerFolderFilter.FOLDERS_ONLY && !isFolder) {
			return false;
		}
		// FILES_AND_FOLDERS — no folder-level filtering

		if (allowedContentTypes && allowedContentTypes.length > 0) {
			return allowedContentTypes
				.map((contentTypeReference) => contentTypeReference.unique)
				.includes(item.mediaType.unique);
		}

src/Umbraco.Web.UI.Client/src/packages/media/media/property-editors/media-entity-picker/property-editor-ui-media-entity-picker.element.ts:3

  • UmbMediaPickerFolderFilter is already re-exported via ../../components/index.js (through input-media/index.ts). Importing it directly from ../../components/input-media/input-media.context.js creates an unnecessary deep import and makes the property editor more coupled to internal file structure; consider importing it from the components barrel to keep imports consistent.
import { UmbMediaPickerFolderFilter } from '../../components/input-media/input-media.context.js';
import type { UmbInputMediaElement } from '../../components/index.js';
import { UmbChangeEvent } from '@umbraco-cms/backoffice/event';

Copy link
Copy Markdown
Member

@leekelleher leekelleher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested out, works as described. 🚀

@nhudinh0309
Copy link
Copy Markdown
Contributor

nhudinh0309 commented Mar 3, 2026

Tests good ✅
Temporarily skipping the failing smoke tests due to the business logic changes.
The fixes for these tests are covered in a separate PR (#21981)

@leekelleher leekelleher merged commit d2a6bd0 into main Mar 3, 2026
28 of 29 checks passed
@leekelleher leekelleher deleted the v17/bugfix/handle-file-and-folder-options-in-media-picker branch March 3, 2026 05:12
@umbracocommunity
Copy link
Copy Markdown

This pull request has been mentioned on Umbraco community forum. There might be relevant details there:

https://forum.umbraco.com/t/unable-to-select-folder-with-media-picker-since-upgrade-to-umbraco-17-3/7807/2

@umbracocommunity
Copy link
Copy Markdown

This pull request has been mentioned on Umbraco community forum. There might be relevant details there:

https://forum.umbraco.com/t/unable-to-select-folder-with-media-picker-since-upgrade-to-umbraco-17-3/7807/5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

V17 Unable to select a media folder as an "Image Upload Folder"

6 participants