Media picker: Fix image selection after upload when media picker presents multiple pages (closes #21115)#21117
Merged
kjac merged 2 commits intorelease/13.13from Dec 17, 2025
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a regression where uploaded images were not automatically selected when the media picker displayed multiple pages. The fix adds logic to navigate to the last page after upload (where new items appear) before attempting to select the newly uploaded items.
Key changes:
- After upload completion and folder refresh, check if there are multiple pages
- If multiple pages exist, navigate to the last page where new uploads appear
- Then proceed with existing selection logic for the uploaded items
Comments suppressed due to low confidence (1)
src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/mediapicker/mediapicker.controller.js:387
- The selection logic fails when more files are uploaded than fit on the last page. For example, if uploading 10 files to a folder with 95 items (pageSize=100), the last page would have only 5 items (101-105), but
files.lengthis 10. The calculation$scope.images.length - files.lengthbecomes negative (5 - 10 = -5), causing_.rest()to return all 5 items instead of the correct subset. Additionally, this assumes newly uploaded items always have the highest IDs and appear on the last page, which may not be true if items are ordered differently or if IDs are not sequential. Consider tracking the actual uploaded file IDs returned from the upload operation and selecting items by matching those IDs.
var images = _.rest(_.sortBy($scope.images, 'id'), $scope.images.length - files.length);
images.forEach(image => selectMedia(image));
...Umbraco.Web.UI.Client/src/views/common/infiniteeditors/mediapicker/mediapicker.controller.js
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
kjac
approved these changes
Dec 17, 2025
Contributor
kjac
left a comment
There was a problem hiding this comment.
Good stuff. Works like a charm 💯
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Prerequisites
Fixes: #21115
Description
This PR fixes a regression introduced in #20202 that prevented correct automatic selection of an uploaded image when there were more images to display than a single page.
After the upload completes, the code now checks if there are multiple pages and if so, navigates to the last page and selects the newly uploaded image(s) from there.
Testing
To test this fix:
mediapicker.controller.js, line 87.