Skip to content

Conversation

@skogsmaskin
Copy link
Member

@skogsmaskin skogsmaskin commented Nov 20, 2025

Description

This will streamline how inputs handle drag-and-drop and file pasting for upload.

Previously, the drag-and-drop logic was scattered throughout the input components, with each input having its own implementation, resulting in nearly identical functionality everywhere but a lot of duplicated code.

This PR will streamline this interaction through a standard component (UploadTarget). This will keep the input components themselves less complex, ensure the same UX pattern is being used everywhere, and make it easier to refactor this functionality in the future.

This PR will also enable asset source upload support for the Array of Object input with the same component.

I have replaced the resolveUploader concept for asset (file) uploads with a onSelectFile property for the inputs instead, as this should now be delegated to the asset source uploaders instead of the internal Uploader concept. The internal uploader concept is still supported for an Array of Primitives. Dropping a text file on an array of strings will behave exactly as before (populate the array with items from the lines of text).

I had a bit back and forth about whether the new prop should be selectFiles or selectFile, and landed on selectFile. If you need to select multiple files (such as an array), simply call the function multiple times for each file.

Another change with this PR is that when multiple asset sources support uploads, the user will be prompted to select a destination after the files are dropped. Previously, the user had to drop the files into a "destination-bucket". This was a bit much to handle for the user at the same time, and it gave us limited space to explain the differences between the destinations. Although this has not been implemented yet, the plan is to enhance how these destinations are presented to the user at a later point. This change also ensures that the paste and drop actions will function in the same way in this regard.

What to review

Image, File, Array, and Portable Text Input File Uploading.

  • That inputs respect the mime type acceptance as configured on the schema type
  • That the inputs respect readOnly modes.
  • That the inputs look and behave the same as before. The only known difference is for file and image inputs, where the drop file text is moved from inside the components to the drop overlay. This component will now use a more generic text ("Drop to upload") instead of the previously more specific text ("Drop image to upload"). Personally, I find it better to have the exact wording and look for this functionality everywhere (you upload files). There will also be a slight visual change in how the drop files overlay is now rendered.
  • That array

Testing

Use the various inputs in the test studio (file, image, portable text (simple block). Change them to test readOnly and options.accept

Notes for release

  • Dropping files into arrays will now support uploading images and files to the Media Library.
  • Improved how the user chooses destinations for uploads if several destinations are available.

@vercel
Copy link

vercel bot commented Nov 20, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
page-building-studio Ready Ready Preview Comment Dec 3, 2025 11:45am
test-studio Ready Ready Preview Comment Dec 3, 2025 11:45am
3 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
e2e-studio Ignored Ignored Dec 3, 2025 11:45am
studio-workshop Ignored Ignored Preview Dec 3, 2025 11:45am
test-next-studio Ignored Ignored Dec 3, 2025 11:45am

@github-actions
Copy link
Contributor

github-actions bot commented Nov 20, 2025

🧪 E2E Preview environment

🔑 Environment Variables for Local Testing

This is the preview URL for the E2E tests: https://e2e-studio-rd7defxg3.sanity.dev

To run the E2E tests locally, you can use the following environment variables, then run pnpm test:e2e --ui to open the Playwright test runner.

💬 Remember to build the project first with pnpm build:e2e.

  SANITY_E2E_PROJECT_ID=ittbm412
  SANITY_E2E_BASE_URL=https://e2e-studio-rd7defxg3.sanity.dev
  SANITY_E2E_DATASET="update depending the project you want to test (pr-11204-chromium-19892568334 || pr-11204-firefox-19892568334 )"
  SANITY_E2E_DATASET_CHROMIUM=pr-11204-chromium-19892568334
  SANITY_E2E_DATASET_FIREFOX=pr-11204-firefox-19892568334

@github-actions
Copy link
Contributor

🧪 E2E Preview environment

Waiting for preview deployment to finish…

@github-actions
Copy link
Contributor

github-actions bot commented Nov 20, 2025

📊 Playwright Test Report

Download Full E2E Report

This report contains test results, including videos of failing tests.

@skogsmaskin skogsmaskin force-pushed the feat/array-asset-source-upload-support branch from 59ae036 to c13567c Compare November 20, 2025 13:10
@github-actions
Copy link
Contributor

github-actions bot commented Nov 20, 2025

⚡️ Editor Performance Report

Deploying studio and running performance tests…

@github-actions
Copy link
Contributor

github-actions bot commented Nov 20, 2025

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 44.41% 64040 / 144172
🔵 Statements 44.41% 64040 / 144172
🔵 Functions 48.22% 3414 / 7079
🔵 Branches 79.34% 13015 / 16403
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/sanity/src/core/components/previews/portableText/BlockPreview.tsx 27.58% 100% 0% 27.58% 26-85
packages/sanity/src/core/form/inputs/PortableText/Compositor.tsx 6.81% 100% 0% 6.81% 52-521
packages/sanity/src/core/form/inputs/PortableText/PortableTextInput.tsx 9.53% 66.66% 25% 9.53% 58-60, 67-74, 99-516, 539-541
packages/sanity/src/core/form/inputs/PortableText/object/BlockObject.tsx 11.2% 100% 0% 11.2% 89-362, 367-459
packages/sanity/src/core/form/inputs/arrays/ArrayOfObjectsInput/Grid/GridArrayInput.tsx 13.92% 100% 0% 13.92% 21-116
packages/sanity/src/core/form/inputs/arrays/ArrayOfObjectsInput/List/ListArrayInput.tsx 13.4% 100% 0% 13.4% 19-136
packages/sanity/src/core/form/inputs/arrays/ArrayOfPrimitivesInput/ArrayOfPrimitivesInput.tsx 7.6% 0% 0% 7.6% 30-244
packages/sanity/src/core/form/inputs/files/FileInput/FileAsset.tsx 84.14% 74.07% 60% 84.14% 47-49, 57-59, 67, 73-75, 80-83
packages/sanity/src/core/form/inputs/files/ImageInput/ImageInput.tsx 6.37% 100% 0% 6.37% 47-557, 564-566
packages/sanity/src/core/form/inputs/files/ImageInput/ImageInputAsset.tsx 13.11% 100% 0% 13.11% 14-108
packages/sanity/src/core/form/inputs/files/ImageInput/ImageInputAssetMenu.tsx 9.55% 100% 0% 9.55% 17-122, 127-251
packages/sanity/src/core/form/inputs/files/ImageInput/ImageInputPreview.tsx 18.75% 100% 0% 18.75% 18-72
packages/sanity/src/core/form/inputs/files/ImageInput/ImageInputUploadPlaceholder.tsx 16.66% 100% 0% 16.66% 8-38
packages/sanity/src/core/form/inputs/files/ImageInput/ImagePreview.tsx 13.33% 100% 0% 13.33% 13-54
packages/sanity/src/core/form/inputs/files/common/DropMessage.tsx 14.54% 100% 0% 14.54% 24-74
packages/sanity/src/core/form/inputs/files/common/PlaceholderText.tsx 83.72% 72.72% 100% 83.72% 53-60
packages/sanity/src/core/form/inputs/files/common/UploadDestinationPicker.tsx 8.33% 100% 0% 8.33% 17-85
packages/sanity/src/core/form/inputs/files/common/UploadPlaceholder.tsx 82.1% 42.85% 50% 82.1% 62-64, 73-74, 84-86, 92-100
packages/sanity/src/core/form/inputs/files/common/assetSource.ts 4.95% 100% 0% 4.95% 29-137
packages/sanity/src/core/form/inputs/files/common/styles.ts 100% 100% 100% 100%
packages/sanity/src/core/form/inputs/files/common/uploadTarget/uploadTarget.tsx 28.44% 100% 20% 28.44% 61-157, 166-185, 191-199, 210-215, 222-224, 238-242, 255-257, 266-314
packages/sanity/src/core/form/members/object/fields/ArrayOfObjectsField.tsx 6.07% 100% 0% 6.07% 70-596
packages/sanity/src/core/form/studio/assetSourceMediaLibrary/constants.ts 100% 100% 100% 100%
packages/sanity/src/core/form/studio/uploads/resolveUploadAssetSources.ts 51.72% 28.57% 100% 51.72% 16-23, 26-27, 29-30, 33-34
packages/sanity/src/core/form/studio/uploads/types.ts 0% 0% 0% 0%
packages/sanity/src/core/form/types/inputProps.ts 0% 0% 0% 0%
packages/sanity/src/core/hooks/useGlobalCopyPasteElementHandler.ts 22.5% 100% 0% 22.5% 27-72
packages/sanity/src/media-library/plugin/VideoInput/VideoAsset.tsx 7.65% 100% 0% 7.65% 26-28, 31-330
Generated in workflow #47008 for commit 1423abf by the Vitest Coverage Report Action

@skogsmaskin skogsmaskin force-pushed the feat/array-asset-source-upload-support branch from c13567c to a93dd2a Compare November 21, 2025 12:56
@skogsmaskin skogsmaskin force-pushed the feat/array-asset-source-upload-support branch from a93dd2a to 4ba6d0c Compare November 21, 2025 13:06
@skogsmaskin skogsmaskin force-pushed the feat/array-asset-source-upload-support branch from 4ba6d0c to b954bba Compare November 21, 2025 13:21
@skogsmaskin skogsmaskin force-pushed the feat/array-asset-source-upload-support branch from b954bba to 98158c7 Compare November 21, 2025 14:11
@skogsmaskin skogsmaskin marked this pull request as ready for review November 21, 2025 14:11
@skogsmaskin skogsmaskin requested a review from a team as a code owner November 21, 2025 14:11
@skogsmaskin skogsmaskin requested review from bjoerge and removed request for a team November 21, 2025 14:11
@skogsmaskin skogsmaskin force-pushed the feat/array-asset-source-upload-support branch from 98158c7 to 2cf9cc3 Compare November 24, 2025 09:35
@skogsmaskin skogsmaskin force-pushed the feat/array-asset-source-upload-support branch from 2cf9cc3 to aa97f46 Compare November 25, 2025 12:51
@skogsmaskin skogsmaskin force-pushed the feat/array-asset-source-upload-support branch from 2e5d77e to 277faa4 Compare November 25, 2025 16:11
@skogsmaskin skogsmaskin force-pushed the feat/array-asset-source-upload-support branch from 277faa4 to b6a5dc9 Compare November 26, 2025 12:21
@skogsmaskin skogsmaskin force-pushed the feat/array-asset-source-upload-support branch from b6a5dc9 to 2010bb5 Compare November 27, 2025 06:12
@skogsmaskin skogsmaskin force-pushed the feat/array-asset-source-upload-support branch from 91a68cd to ff3fd90 Compare November 27, 2025 08:00
@skogsmaskin skogsmaskin force-pushed the feat/array-asset-source-upload-support branch from ff3fd90 to e101d07 Compare November 28, 2025 15:19
@skogsmaskin skogsmaskin force-pushed the feat/array-asset-source-upload-support branch from e101d07 to 4e0bb58 Compare December 1, 2025 11:57
@skogsmaskin skogsmaskin force-pushed the feat/array-asset-source-upload-support branch from 4e0bb58 to 114dd48 Compare December 1, 2025 15:26
@skogsmaskin skogsmaskin force-pushed the feat/array-asset-source-upload-support branch from 114dd48 to afc8c7b Compare December 2, 2025 11:28
This will streamline how inputs handle drag and drop + paste files.

It will add asset source support to array of object uploads as well.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants