From a19441e5527fd1bfb7df19e07a40652a6630886d Mon Sep 17 00:00:00 2001 From: ntsekouras Date: Wed, 4 Feb 2026 11:03:45 +0200 Subject: [PATCH 01/30] MediaEdit: Preserve order of items --- .../src/components/media-edit/index.tsx | 194 ++++++++++++------ 1 file changed, 130 insertions(+), 64 deletions(-) diff --git a/packages/fields/src/components/media-edit/index.tsx b/packages/fields/src/components/media-edit/index.tsx index 862eac92b74407..cb269108bdd4e5 100644 --- a/packages/fields/src/components/media-edit/index.tsx +++ b/packages/fields/src/components/media-edit/index.tsx @@ -59,6 +59,13 @@ type BlobItem = { alt_text?: string; }; +function normalizeValue( value: number | number[] | undefined ): number[] { + if ( Array.isArray( value ) ) { + return value; + } + return value ? [ value ] : []; +} + /** * Conditional Media component that uses MediaUploadModal when experiment is enabled, * otherwise falls back to media-utils MediaUpload. @@ -225,6 +232,7 @@ interface MediaEditAttachmentsProps { open: () => void; onFilesDrop: ( files: File[], attachmentId?: number ) => void; isUploading: boolean; + setTargetItemId: ( id?: number ) => void; } function ExpandedMediaEditAttachments( { @@ -235,6 +243,7 @@ function ExpandedMediaEditAttachments( { open, onFilesDrop, isUploading, + setTargetItemId, }: MediaEditAttachmentsProps ) { return (
{ + setTargetItemId( attachment.id as number ); + open(); + } } label={ __( 'Replace' ) } showTooltip onFilesDrop={ onFilesDrop } @@ -320,7 +332,10 @@ function ExpandedMediaEditAttachments( { } ) } { ( multiple || ! allItems?.length ) && ( { + setTargetItemId( undefined ); + open(); + } } label={ addButtonLabel } onFilesDrop={ onFilesDrop } isUploading={ isUploading } @@ -338,6 +353,7 @@ function CompactMediaEditAttachments( { open, onFilesDrop, isUploading, + setTargetItemId, }: MediaEditAttachmentsProps ) { return ( <> @@ -351,7 +367,12 @@ function CompactMediaEditAttachments( { className="fields__media-edit-compact" > { + setTargetItemId( + attachment.id as number + ); + open(); + } } label={ __( 'Replace' ) } showTooltip onFilesDrop={ onFilesDrop } @@ -396,7 +417,10 @@ function CompactMediaEditAttachments( { ) } { ( multiple || ! allItems?.length ) && ( { + setTargetItemId( undefined ); + open(); + } } label={ addButtonLabel } onFilesDrop={ onFilesDrop } isUploading={ isUploading } @@ -477,17 +501,18 @@ export default function MediaEdit< Item >( { if ( ! value ) { return null; } - const normalizedValue = Array.isArray( value ) ? value : [ value ]; + const normalizedValue = normalizeValue( value ); const { getEntityRecords } = select( coreStore ); return getEntityRecords( 'postType', 'attachment', { include: normalizedValue, + orderby: 'include', } ) as Attachment< 'view' >[] | null; }, [ value ] ); const { createErrorNotice } = useDispatch( noticesStore ); // Support one upload action at a time for now. - const [ replacementId, setReplacementId ] = useState< number >(); + const [ targetItemId, setTargetItemId ] = useState< number >(); const [ blobs, setBlobs ] = useState< string[] >( [] ); const onChangeControl = useCallback( ( newValue: number | number[] | undefined ) => @@ -496,7 +521,7 @@ export default function MediaEdit< Item >( { ); const removeItem = useCallback( ( itemId: number ) => { - const currentIds = Array.isArray( value ) ? value : [ value ]; + const currentIds = normalizeValue( value ); const newIds = currentIds.filter( ( id ) => id !== itemId ); // Mark as touched to immediately show any validation error. setIsTouched( true ); @@ -505,57 +530,46 @@ export default function MediaEdit< Item >( { [ value, onChangeControl ] ); const onFilesDrop = useCallback( - ( files: File[], _replacementId?: number ) => { + ( files: File[], _targetItemId?: number ) => { + setTargetItemId( _targetItemId ); uploadMedia( { allowedTypes: allowedTypes?.length ? allowedTypes : undefined, filesList: files, onFileChange( uploadedMedia: any[] ) { - setReplacementId( _replacementId ); - const { blobItems, uploadedItems } = uploadedMedia.reduce( - ( accumulator, item ) => { - if ( isBlobURL( item.url ) ) { - accumulator.blobItems.push( item.url ); - } else { - accumulator.uploadedItems.push( item.id ); - } - return accumulator; - }, - { - blobItems: [] as string[], - uploadedItems: [] as number[], - } - ); - setBlobs( blobItems ); - // If all uploads are complete reset the replacementId. - if ( uploadedItems.length === uploadedMedia.length ) { - setReplacementId( undefined ); - } - if ( ! uploadedItems.length ) { + const blobUrls = uploadedMedia + .filter( ( item ) => isBlobURL( item.url ) ) + .map( ( item ) => item.url ); + setBlobs( blobUrls ); + // Wait for all uploads to complete before updating value. + if ( !! blobUrls.length ) { return; } + const uploadedIds = uploadedMedia.map( + ( item ) => item.id + ); if ( ! multiple ) { - onChangeControl( uploadedItems[ 0 ] ); + onChangeControl( uploadedIds[ 0 ] ); + setTargetItemId( undefined ); return; } - if ( ! value ) { - onChangeControl( uploadedItems ); - return; + const currentValue = normalizeValue( value ); + // Dropped on placeholder: append new items. + if ( _targetItemId === undefined ) { + onChangeControl( [ ...currentValue, ...uploadedIds ] ); + } else { + // Dropped on existing item: insert at that position. + const newValue = [ ...currentValue ]; + newValue.splice( + currentValue.indexOf( _targetItemId ), + 1, + ...uploadedIds + ); + onChangeControl( newValue ); } - const normalizedValue = Array.isArray( value ) - ? value - : [ value ]; - const newIds = [ - ...( _replacementId - ? normalizedValue.filter( - ( id: any ) => id !== _replacementId - ) - : normalizedValue ), - ...uploadedItems, - ]; - onChangeControl( newIds ); + setTargetItemId( undefined ); }, onError( error: Error ) { - setReplacementId( undefined ); + setTargetItemId( undefined ); setBlobs( [] ); createErrorNotice( error.message, { type: 'snackbar' } ); }, @@ -580,21 +594,17 @@ export default function MediaEdit< Item >( { source_url: url, mime_type: getBlobTypeByURL( url ), } ) ); - const replacementIndex = items.findIndex( - ( a ) => a.id === replacementId - ); - // Place blobs at the replacement index, when files - // dropped in existing media item. - if ( replacementIndex !== -1 ) { - return [ - ...items.slice( 0, replacementIndex ), - ...blobItems, - ...items.slice( replacementIndex + 1 ), - ]; + if ( targetItemId !== undefined ) { + // When files dropped in existing media item, place the blobs at that item. + const targetIndex = items.findIndex( + ( a ) => a.id === targetItemId + ); + items.splice( targetIndex, 1, ...blobItems ); + } else { + items.push( ...blobItems ); } - items.push( ...blobItems ); return items; - }, [ attachments, replacementId, blobs ] ); + }, [ attachments, targetItemId, blobs ] ); useEffect( () => { if ( ! isTouched ) { return; @@ -640,15 +650,70 @@ export default function MediaEdit< Item >( {
{ - if ( multiple ) { - const newIds = Array.isArray( selectedMedia ) - ? selectedMedia.map( ( m: any ) => m.id ) - : [ selectedMedia.id ]; + if ( ! multiple ) { + onChangeControl( selectedMedia.id ); + setTargetItemId( undefined ); + return; + } + const newIds = Array.isArray( selectedMedia ) + ? selectedMedia.map( ( m: any ) => m.id ) + : [ selectedMedia.id ]; + const currentValue = normalizeValue( value ); + if ( ! currentValue.length ) { onChangeControl( newIds ); + } else if ( targetItemId === undefined ) { + // Placeholder clicked: keep existing items that are + // still selected, then append newly selected items. + const existingItems = currentValue.filter( ( id ) => + newIds.includes( id ) + ); + const newItems = newIds.filter( + ( id ) => ! currentValue.includes( id ) + ); + onChangeControl( [ + ...existingItems, + ...newItems, + ] ); } else { - onChangeControl( selectedMedia.id ); + // Existing item clicked (`replace`): insert newly + // selected items at that position and remove any + // other items that were deselected. + const isClickedItemStillSelected = + newIds.includes( targetItemId ); + const newItems = newIds.filter( + ( id ) => ! currentValue.includes( id ) + ); + // Keep only items that are still selected. + const keptItems = currentValue.filter( ( id ) => + newIds.includes( id ) + ); + // Find insert position based on where target was. + const originalTargetIndex = + currentValue.indexOf( targetItemId ); + const insertIndex = currentValue + .slice( 0, originalTargetIndex ) + .filter( ( id ) => + newIds.includes( id ) + ).length; + // Insert new items at target position. + const newValue = [ ...keptItems ]; + newValue.splice( + insertIndex + + ( isClickedItemStillSelected ? 1 : 0 ), + 0, + ...newItems + ); + onChangeControl( newValue ); } + setTargetItemId( undefined ); } } allowedTypes={ allowedTypes } value={ value } @@ -678,6 +743,7 @@ export default function MediaEdit< Item >( { open={ open } onFilesDrop={ onFilesDrop } isUploading={ !! blobs.length } + setTargetItemId={ setTargetItemId } /> { field.description && ( From 0b5fe80650d5b2b37ab8626618c4570cfd6d9aab Mon Sep 17 00:00:00 2001 From: ntsekouras Date: Wed, 4 Feb 2026 11:04:04 +0200 Subject: [PATCH 02/30] test code for MediaEdit in site editor - quick edit --- lib/compat/wordpress-7.0/media-edit-test.php | 68 +++++++++++++++++++ lib/load.php | 1 + .../src/dataviews/store/private-actions.ts | 2 + packages/fields/README.md | 4 ++ packages/fields/src/fields/index.ts | 1 + .../fields/media-edit-test-fields/index.tsx | 58 ++++++++++++++++ 6 files changed, 134 insertions(+) create mode 100644 lib/compat/wordpress-7.0/media-edit-test.php create mode 100644 packages/fields/src/fields/media-edit-test-fields/index.tsx diff --git a/lib/compat/wordpress-7.0/media-edit-test.php b/lib/compat/wordpress-7.0/media-edit-test.php new file mode 100644 index 00000000000000..0c1a48f9911d79 --- /dev/null +++ b/lib/compat/wordpress-7.0/media-edit-test.php @@ -0,0 +1,68 @@ + true ) ); + + // Define test fields: name => is_array. + $fields = array( + 'test_media_gallery' => true, // array - multiple+expanded. + 'test_media_gallery_2' => true, // array - multiple+compact. + 'test_media_single' => false, // integer - single+expanded. + ); + + foreach ( $post_types as $post_type ) { + foreach ( $fields as $field_name => $is_array ) { + register_rest_field( + $post_type, + $field_name, + array( + 'schema' => $is_array + ? array( + 'type' => 'array', + 'items' => array( 'type' => 'integer' ), + 'context' => array( 'view', 'edit' ), + 'default' => array(), + ) + : array( + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'default' => 0, + ), + 'get_callback' => function ( $object ) use ( $field_name, $is_array ) { + if ( ! isset( $object['id'] ) ) { + return $is_array ? array() : 0; + } + $meta = get_post_meta( $object['id'], $field_name, true ); + if ( $is_array ) { + return ( empty( $meta ) || ! is_array( $meta ) ) ? array() : array_map( 'intval', $meta ); + } + return $meta ? intval( $meta ) : 0; + }, + 'update_callback' => function ( $value, $object ) use ( $field_name, $is_array ) { + if ( $is_array ) { + $value = is_array( $value ) ? array_map( 'intval', $value ) : ( $value ? array( intval( $value ) ) : array() ); + } else { + $value = intval( $value ); + } + update_post_meta( $object->ID, $field_name, $value ); + return true; + }, + ) + ); + } + } +} +add_action( 'rest_api_init', 'gutenberg_register_media_edit_test_rest_fields' ); diff --git a/lib/load.php b/lib/load.php index aaf972cdeb356f..d5285d1cb8a743 100644 --- a/lib/load.php +++ b/lib/load.php @@ -71,6 +71,7 @@ function gutenberg_is_experiment_enabled( $name ) { require __DIR__ . '/compat/wordpress-7.0/class-gutenberg-rest-static-templates-controller.php'; require __DIR__ . '/compat/wordpress-7.0/template-activate.php'; require __DIR__ . '/compat/wordpress-7.0/rest-api.php'; + require __DIR__ . '/compat/wordpress-7.0/media-edit-test.php'; require __DIR__ . '/compat/wordpress-7.0/global-styles.php'; // Plugin specific code. diff --git a/packages/editor/src/dataviews/store/private-actions.ts b/packages/editor/src/dataviews/store/private-actions.ts index f8bf67e55921a9..ecdd209dba1a2d 100644 --- a/packages/editor/src/dataviews/store/private-actions.ts +++ b/packages/editor/src/dataviews/store/private-actions.ts @@ -35,6 +35,7 @@ import { pageTitleField, patternTitleField, notesField, + mediaEditTestFields, } from '@wordpress/fields'; import { altTextField, @@ -272,6 +273,7 @@ export const registerPostTypeSchema = postPreviewField, hasEditorNotesSupport( postTypeConfig.supports ) && notesField, ].filter( Boolean ); + fields.push( ...mediaEditTestFields ); // Add the media test fields. if ( postTypeConfig.supports?.title ) { let _titleField; if ( postType === 'page' ) { diff --git a/packages/fields/README.md b/packages/fields/README.md index fa190b8f47aa3c..0c52b7ed37fad8 100644 --- a/packages/fields/README.md +++ b/packages/fields/README.md @@ -112,6 +112,10 @@ _Returns_ Undocumented declaration. +### mediaEditTestFields + +Undocumented declaration. + ### notesField Notes count field for post types that support editor.notes. diff --git a/packages/fields/src/fields/index.ts b/packages/fields/src/fields/index.ts index fb23ccbfb2c1a5..b72013c9409520 100644 --- a/packages/fields/src/fields/index.ts +++ b/packages/fields/src/fields/index.ts @@ -15,3 +15,4 @@ export { default as discussionField } from './discussion'; export { default as dateField } from './date'; export { default as authorField } from './author'; export { default as notesField } from './notes'; +export { mediaEditTestFields } from './media-edit-test-fields'; diff --git a/packages/fields/src/fields/media-edit-test-fields/index.tsx b/packages/fields/src/fields/media-edit-test-fields/index.tsx new file mode 100644 index 00000000000000..124eb0db9afd1f --- /dev/null +++ b/packages/fields/src/fields/media-edit-test-fields/index.tsx @@ -0,0 +1,58 @@ +/** + * WordPress dependencies + */ +import type { Field } from '@wordpress/dataviews'; +import { __ } from '@wordpress/i18n'; + +/** + * Internal dependencies + */ +import MediaEdit from '../../components/media-edit'; +import type { BasePost } from '../../types'; + +interface BasePostWithTestMeta extends BasePost { + test_media_gallery?: number[]; + test_media_gallery_2?: number[]; + test_media_single?: number; +} + +const sharedConfig = { + type: 'media', + enableSorting: false, + filterBy: false, +} as const; + +export const mediaEditTestFields: Field< BasePostWithTestMeta >[] = [ + { + ...sharedConfig, + id: 'test_media_gallery', + label: __( 'Test Gallery (Expanded)' ), + Edit: ( props ) => , + getValue: ( { item } ) => item.test_media_gallery, + setValue: ( { value } ) => ( { + test_media_gallery: Array.isArray( value ) ? value : [], + } ), + }, + { + ...sharedConfig, + id: 'test_media_gallery_2', + label: __( 'Test Gallery (Compact)' ), + Edit: ( props ) => ( + + ), + getValue: ( { item } ) => item.test_media_gallery_2, + setValue: ( { value } ) => ( { + test_media_gallery_2: Array.isArray( value ) ? value : [], + } ), + }, + { + ...sharedConfig, + id: 'test_media_single', + label: __( 'Test Single (Expanded)' ), + Edit: ( props ) => , + getValue: ( { item } ) => item.test_media_single, + setValue: ( { value } ) => ( { test_media_single: value ?? 0 } ), + }, +]; + +export default mediaEditTestFields; From c0cf9aed3141251b508e158068b3ca209971a9c3 Mon Sep 17 00:00:00 2001 From: ntsekouras Date: Wed, 4 Feb 2026 14:13:37 +0200 Subject: [PATCH 03/30] add re-order (mover buttons) --- .../src/components/media-edit/index.tsx | 194 ++++++++++++++---- .../src/components/media-edit/style.scss | 42 +++- 2 files changed, 193 insertions(+), 43 deletions(-) diff --git a/packages/fields/src/components/media-edit/index.tsx b/packages/fields/src/components/media-edit/index.tsx index cb269108bdd4e5..faff0df180e462 100644 --- a/packages/fields/src/components/media-edit/index.tsx +++ b/packages/fields/src/components/media-edit/index.tsx @@ -14,6 +14,7 @@ import { __experimentalText as Text, __experimentalTruncate as Truncate, __experimentalVStack as VStack, + __experimentalHStack as HStack, BaseControl, Tooltip, VisuallyHidden, @@ -36,6 +37,10 @@ import { file, closeSmall, error as errorIcon, + chevronUp, + chevronDown, + chevronLeft, + chevronRight, } from '@wordpress/icons'; import { MediaUpload, @@ -202,6 +207,52 @@ function MediaEditPlaceholder( props: { ); } +function MoveButtons( { + itemId, + index, + totalItems, + isUploading, + moveItem, + orientation = 'vertical', +}: { + itemId: number; + index: number; + totalItems: number; + isUploading: boolean; + moveItem: ( id: number, direction: 'up' | 'down' ) => void; + orientation?: 'vertical' | 'horizontal'; +} ) { + const isHorizontal = orientation === 'horizontal'; + return ( + <> +
) }
@@ -350,6 +421,7 @@ function CompactMediaEditAttachments( { addButtonLabel, multiple, removeItem, + moveItem, open, onFilesDrop, isUploading, @@ -359,39 +431,64 @@ function CompactMediaEditAttachments( { <> { !! allItems?.length && ( - { allItems.map( ( attachment ) => { + { allItems.map( ( attachment, index ) => { const isBlob = isBlobURL( attachment.source_url ); return (
- { - setTargetItemId( - attachment.id as number - ); - open(); - } } - label={ __( 'Replace' ) } - showTooltip - onFilesDrop={ onFilesDrop } - attachment={ attachment } - isUploading={ isUploading } - > - <> - - { ! isBlob && ( - - } +
+ { + setTargetItemId( + attachment.id as number + ); + open(); + } } + label={ __( 'Replace' ) } + showTooltip + onFilesDrop={ onFilesDrop } + attachment={ attachment } + isUploading={ isUploading } + > + <> + + { ! isBlob && ( + + } + /> + ) } + + + { ! isBlob && + multiple && + !! allItems?.length && ( + + + ) } - - +
- ) } - + ); + } } + /> + + + ) } + + ); } ) } { ( multiple || ! allItems?.length ) && ( @@ -438,81 +454,86 @@ function CompactMediaEditAttachments( { { allItems.map( ( attachment, index ) => { const isBlob = isBlobURL( attachment.source_url ); return ( -
-
- { - setTargetItemId( - attachment.id as number - ); - open(); - } } - label={ __( 'Replace' ) } - showTooltip - onFilesDrop={ onFilesDrop } - attachment={ attachment } - isUploading={ isUploading } - > - <> - - { ! isBlob && ( - - } +
+
+ { + setTargetItemId( + attachment.id as number + ); + open(); + } } + label={ __( 'Replace' ) } + showTooltip + onFilesDrop={ onFilesDrop } + attachment={ attachment } + isUploading={ isUploading } + > + <> + + { ! isBlob && ( + + } + /> + ) } + + + { ! isBlob && + multiple && + allItems && + allItems.length > 1 && ( + + + ) } - - - { ! isBlob && - multiple && - allItems && - allItems.length > 1 && ( - - - - ) } +
+
-
+ ); } ) } diff --git a/packages/fields/src/components/media-edit/use-moving-animation.ts b/packages/fields/src/components/media-edit/use-moving-animation.ts new file mode 100644 index 00000000000000..fe71023462724a --- /dev/null +++ b/packages/fields/src/components/media-edit/use-moving-animation.ts @@ -0,0 +1,79 @@ +/** + * External dependencies + */ +import { Controller } from '@react-spring/web'; + +/** + * WordPress dependencies + */ +import { useLayoutEffect, useRef } from '@wordpress/element'; + +function getAbsolutePosition( element: HTMLElement ) { + return { + top: element.offsetTop, + left: element.offsetLeft, + }; +} + +/** + * Hook used to compute the styles required to move a div into a new position. + * + * The way this animation works is the following: + * - It first renders the element as if there was no animation. + * - It takes a snapshot of the position of the element to use it + * as a destination point for the animation. + * - It restores the element to the previous position using a CSS transform + * - It uses the "resetAnimation" flag to reset the animation + * from the beginning in order to animate to the new destination point. + * + * @param triggerAnimationOnChange Variable used to trigger the animation if it changes. + */ +export default function useMovingAnimation( + triggerAnimationOnChange: unknown +) { + const ref = useRef< HTMLDivElement >( null ); + const previousRef = useRef< { top: number; left: number } | null >( null ); + // Capture position before DOM updates (during render). + // This runs synchronously during render, before layout effects. + if ( ref.current ) { + previousRef.current = getAbsolutePosition( ref.current ); + } + useLayoutEffect( () => { + const previous = previousRef.current; + if ( ! previous || ! ref.current ) { + return; + } + if ( window.matchMedia( '(prefers-reduced-motion: reduce)' ).matches ) { + return; + } + const controller = new Controller( { + x: 0, + y: 0, + config: { mass: 5, tension: 2000, friction: 200 }, + onChange( { value } ) { + if ( ! ref.current ) { + return; + } + let { x, y } = value; + x = Math.round( x ); + y = Math.round( y ); + const finishedMoving = x === 0 && y === 0; + ref.current.style.transform = finishedMoving + ? '' + : `translate3d(${ x }px,${ y }px,0)`; + }, + } ); + ref.current.style.transform = ''; + const destination = getAbsolutePosition( ref.current ); + const x = Math.round( previous.left - destination.left ); + const y = Math.round( previous.top - destination.top ); + controller.start( { x: 0, y: 0, from: { x, y } } ); + return () => { + controller.stop(); + controller.set( { x: 0, y: 0 } ); + }; + // triggerAnimationOnChange is intentionally the only dependency - we want to + // animate when this value changes, capturing position during render phase. + }, [ triggerAnimationOnChange ] ); + return ref; +} From 310e34ed446816ba9ec39d4562e3158032bc4c78 Mon Sep 17 00:00:00 2001 From: ntsekouras Date: Wed, 4 Feb 2026 16:21:21 +0200 Subject: [PATCH 07/30] fix test code linting --- lib/compat/wordpress-7.0/media-edit-test.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/compat/wordpress-7.0/media-edit-test.php b/lib/compat/wordpress-7.0/media-edit-test.php index 0c1a48f9911d79..2cfd6558b91926 100644 --- a/lib/compat/wordpress-7.0/media-edit-test.php +++ b/lib/compat/wordpress-7.0/media-edit-test.php @@ -41,23 +41,23 @@ function gutenberg_register_media_edit_test_rest_fields() { 'context' => array( 'view', 'edit' ), 'default' => 0, ), - 'get_callback' => function ( $object ) use ( $field_name, $is_array ) { - if ( ! isset( $object['id'] ) ) { + 'get_callback' => function ( $post ) use ( $field_name, $is_array ) { + if ( ! isset( $post['id'] ) ) { return $is_array ? array() : 0; } - $meta = get_post_meta( $object['id'], $field_name, true ); + $meta = get_post_meta( $post['id'], $field_name, true ); if ( $is_array ) { return ( empty( $meta ) || ! is_array( $meta ) ) ? array() : array_map( 'intval', $meta ); } return $meta ? intval( $meta ) : 0; }, - 'update_callback' => function ( $value, $object ) use ( $field_name, $is_array ) { + 'update_callback' => function ( $value, $post ) use ( $field_name, $is_array ) { if ( $is_array ) { $value = is_array( $value ) ? array_map( 'intval', $value ) : ( $value ? array( intval( $value ) ) : array() ); } else { $value = intval( $value ); } - update_post_meta( $object->ID, $field_name, $value ); + update_post_meta( $post->ID, $field_name, $value ); return true; }, ) From 27cd4f0681ad111916454b1cea0ec616ca0e6c20 Mon Sep 17 00:00:00 2001 From: ntsekouras Date: Fri, 6 Feb 2026 13:09:29 +0200 Subject: [PATCH 08/30] register post meta only for pages --- lib/compat/wordpress-7.0/media-edit-test.php | 80 ++++++++++---------- 1 file changed, 38 insertions(+), 42 deletions(-) diff --git a/lib/compat/wordpress-7.0/media-edit-test.php b/lib/compat/wordpress-7.0/media-edit-test.php index 2cfd6558b91926..718c105d5d8870 100644 --- a/lib/compat/wordpress-7.0/media-edit-test.php +++ b/lib/compat/wordpress-7.0/media-edit-test.php @@ -14,8 +14,6 @@ * - test_media_single: integer type for single+expanded testing */ function gutenberg_register_media_edit_test_rest_fields() { - $post_types = get_post_types( array( 'show_in_rest' => true ) ); - // Define test fields: name => is_array. $fields = array( 'test_media_gallery' => true, // array - multiple+expanded. @@ -23,46 +21,44 @@ function gutenberg_register_media_edit_test_rest_fields() { 'test_media_single' => false, // integer - single+expanded. ); - foreach ( $post_types as $post_type ) { - foreach ( $fields as $field_name => $is_array ) { - register_rest_field( - $post_type, - $field_name, - array( - 'schema' => $is_array - ? array( - 'type' => 'array', - 'items' => array( 'type' => 'integer' ), - 'context' => array( 'view', 'edit' ), - 'default' => array(), - ) - : array( - 'type' => 'integer', - 'context' => array( 'view', 'edit' ), - 'default' => 0, - ), - 'get_callback' => function ( $post ) use ( $field_name, $is_array ) { - if ( ! isset( $post['id'] ) ) { - return $is_array ? array() : 0; - } - $meta = get_post_meta( $post['id'], $field_name, true ); - if ( $is_array ) { - return ( empty( $meta ) || ! is_array( $meta ) ) ? array() : array_map( 'intval', $meta ); - } - return $meta ? intval( $meta ) : 0; - }, - 'update_callback' => function ( $value, $post ) use ( $field_name, $is_array ) { - if ( $is_array ) { - $value = is_array( $value ) ? array_map( 'intval', $value ) : ( $value ? array( intval( $value ) ) : array() ); - } else { - $value = intval( $value ); - } - update_post_meta( $post->ID, $field_name, $value ); - return true; - }, - ) - ); - } + foreach ( $fields as $field_name => $is_array ) { + register_rest_field( + 'page', + $field_name, + array( + 'schema' => $is_array + ? array( + 'type' => 'array', + 'items' => array( 'type' => 'integer' ), + 'context' => array( 'view', 'edit' ), + 'default' => array(), + ) + : array( + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'default' => 0, + ), + 'get_callback' => function ( $post ) use ( $field_name, $is_array ) { + if ( ! isset( $post['id'] ) ) { + return $is_array ? array() : 0; + } + $meta = get_post_meta( $post['id'], $field_name, true ); + if ( $is_array ) { + return ( empty( $meta ) || ! is_array( $meta ) ) ? array() : array_map( 'intval', $meta ); + } + return $meta ? intval( $meta ) : 0; + }, + 'update_callback' => function ( $value, $post ) use ( $field_name, $is_array ) { + if ( $is_array ) { + $value = is_array( $value ) ? array_map( 'intval', $value ) : ( $value ? array( intval( $value ) ) : array() ); + } else { + $value = intval( $value ); + } + update_post_meta( $post->ID, $field_name, $value ); + return true; + }, + ) + ); } } add_action( 'rest_api_init', 'gutenberg_register_media_edit_test_rest_fields' ); From 66e563cb5af39f17e0a06fc141011d3c45f114a2 Mon Sep 17 00:00:00 2001 From: ntsekouras Date: Mon, 9 Feb 2026 15:54:02 +0200 Subject: [PATCH 09/30] add test fields in quick edit form --- .../components/post-list/quick-edit-modal.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/packages/edit-site/src/components/post-list/quick-edit-modal.js b/packages/edit-site/src/components/post-list/quick-edit-modal.js index bf4184581bcbb8..33fac709a7df52 100644 --- a/packages/edit-site/src/components/post-list/quick-edit-modal.js +++ b/packages/edit-site/src/components/post-list/quick-edit-modal.js @@ -75,12 +75,21 @@ export function QuickEditModal( { postType, postId, closeModal } ) { const form = useMemo( () => { const allFields = [ + { + id: 'test_media_gallery_2', + layout: { type: 'regular' }, + }, + { + id: 'test_media_gallery', + layout: { type: 'regular' }, + }, { id: 'featured_media', - layout: { - type: 'regular', - labelPosition: 'none', - }, + layout: { type: 'regular' }, + }, + { + id: 'test_media_single', + layout: { type: 'regular' }, }, { id: 'status', From 0aab536b8fc16bf86cbcae176c62e48b4737e9bc Mon Sep 17 00:00:00 2001 From: ntsekouras Date: Mon, 9 Feb 2026 20:03:48 +0200 Subject: [PATCH 10/30] replace one single item in on replace of existing item --- .../src/components/media-edit/index.tsx | 55 ++++++------------- 1 file changed, 17 insertions(+), 38 deletions(-) diff --git a/packages/fields/src/components/media-edit/index.tsx b/packages/fields/src/components/media-edit/index.tsx index 1a12f83673405a..37e5b40936c1c3 100644 --- a/packages/fields/src/components/media-edit/index.tsx +++ b/packages/fields/src/components/media-edit/index.tsx @@ -778,7 +778,7 @@ export default function MediaEdit< Item >( { customValidityResult.message || __( 'Invalid' ) ); } else { - input.setCustomValidity( '' ); // Clear validity + input.setCustomValidity( '' ); // Clear validity. } } else { // Clear any previous validation. @@ -804,13 +804,6 @@ export default function MediaEdit< Item >( {
{ if ( ! multiple ) { onChangeControl( selectedMedia.id ); @@ -836,42 +829,28 @@ export default function MediaEdit< Item >( { ...existingItems, ...newItems, ] ); - } else { - // Existing item clicked (`replace`): insert newly - // selected items at that position and remove any - // other items that were deselected. - const isClickedItemStillSelected = - newIds.includes( targetItemId ); - const newItems = newIds.filter( - ( id ) => ! currentValue.includes( id ) - ); - // Keep only items that are still selected. - const keptItems = currentValue.filter( ( id ) => - newIds.includes( id ) + } else if ( selectedMedia.id !== targetItemId ) { + // Remove selected item from its old position, if it + // already exists in the value. + const filtered = currentValue.filter( + ( id ) => id !== selectedMedia.id ); - // Find insert position based on where target was. - const originalTargetIndex = - currentValue.indexOf( targetItemId ); - const insertIndex = currentValue - .slice( 0, originalTargetIndex ) - .filter( ( id ) => - newIds.includes( id ) - ).length; - // Insert new items at target position. - const newValue = [ ...keptItems ]; - newValue.splice( - insertIndex + - ( isClickedItemStillSelected ? 1 : 0 ), - 0, - ...newItems + // Replace the clicked item with the selected one. + onChangeControl( + filtered.map( ( id ) => + id === targetItemId ? selectedMedia.id : id + ) ); - onChangeControl( newValue ); } setTargetItemId( undefined ); } } + onClose={ () => setTargetItemId( undefined ) } allowedTypes={ allowedTypes } - value={ value } - multiple={ multiple } + // When replacing an existing item, pass only that item's ID + // and open in single-select mode so the user picks exactly + // one replacement, even if `multiple` is true. ` + value={ targetItemId !== undefined ? targetItemId : value } + multiple={ multiple && targetItemId === undefined } title={ field.label } render={ ( { open }: any ) => { const AttachmentsComponent = isExpanded From 575752b03bba8977add83a5b72db7e055093af62 Mon Sep 17 00:00:00 2001 From: ntsekouras Date: Tue, 10 Feb 2026 16:21:54 +0200 Subject: [PATCH 11/30] update compact designs --- .../src/components/media-edit/index.tsx | 176 +++++++++--------- .../src/components/media-edit/style.scss | 36 ++-- 2 files changed, 113 insertions(+), 99 deletions(-) diff --git a/packages/fields/src/components/media-edit/index.tsx b/packages/fields/src/components/media-edit/index.tsx index 37e5b40936c1c3..89ce81ea0c08e8 100644 --- a/packages/fields/src/components/media-edit/index.tsx +++ b/packages/fields/src/components/media-edit/index.tsx @@ -61,12 +61,18 @@ const { MediaUploadModal } = unlock( mediaUtilsPrivateApis ); function AnimatedMediaItem( { children, index, + className, }: { children: React.ReactNode; index: number; + className?: string; } ) { const ref = useMovingAnimation( index ); - return
{ children }
; + return ( +
+ { children } +
+ ); } type BlobItem = { @@ -450,93 +456,93 @@ function CompactMediaEditAttachments( { return ( <> { !! allItems?.length && ( - - { allItems.map( ( attachment, index ) => { - const isBlob = isBlobURL( attachment.source_url ); - return ( - -
-
- { - setTargetItemId( - attachment.id as number - ); - open(); - } } - label={ __( 'Replace' ) } - showTooltip - onFilesDrop={ onFilesDrop } - attachment={ attachment } - isUploading={ isUploading } +
+ + { allItems.map( ( attachment, index ) => { + const isBlob = isBlobURL( attachment.source_url ); + const showMoveButtons = + multiple && allItems && allItems.length > 1; + return ( + + { + setTargetItemId( + attachment.id as number + ); + open(); + } } + label={ __( 'Replace' ) } + showTooltip + onFilesDrop={ onFilesDrop } + attachment={ attachment } + isUploading={ isUploading } + > + <> + + { ! isBlob && ( + + } + /> + ) } + + + { ! isBlob && ( + - <> - - { ! isBlob && ( - - } - /> - ) } - - - { ! isBlob && - multiple && - allItems && - allItems.length > 1 && ( - - - ) } -
-
- - ); - } ) } - +
) } { ( multiple || ! allItems?.length ) && ( div > .fields__media-edit-compact:not(:last-child) { + border-bottom: $border-width solid $gray-300; + } + } + .fields__media-edit-compact { - display: grid; - grid-template-columns: 1fr auto; - gap: $grid-unit-10; - align-items: center; @include compact-drop-zone-label; + position: relative; + min-width: 0; - .fields__media-edit-compact-item { - position: relative; - min-width: 0; - flex: 1; - - &:hover, - &:focus-within { - .fields__media-edit-compact-movers { - opacity: 1; - } + &:hover, + &:focus-within { + .fields__media-edit-compact-movers { + opacity: 1; } } From a9d33a2109703fc219c83bff7ee61a129bfc664c Mon Sep 17 00:00:00 2001 From: ntsekouras Date: Tue, 10 Feb 2026 16:31:18 +0200 Subject: [PATCH 12/30] remove extra wrapper from expanded --- .../src/components/media-edit/index.tsx | 179 +++++++++--------- 1 file changed, 88 insertions(+), 91 deletions(-) diff --git a/packages/fields/src/components/media-edit/index.tsx b/packages/fields/src/components/media-edit/index.tsx index 89ce81ea0c08e8..725b74c45ff9cf 100644 --- a/packages/fields/src/components/media-edit/index.tsx +++ b/packages/fields/src/components/media-edit/index.tsx @@ -329,101 +329,98 @@ function ExpandedMediaEditAttachments( { attachment.mime_type?.startsWith( 'image' ); const isBlob = isBlobURL( attachment.source_url ); return ( - -
+ { + setTargetItemId( attachment.id as number ); + open(); + } } + label={ __( 'Replace' ) } + showTooltip + onFilesDrop={ onFilesDrop } + attachment={ attachment } + isUploading={ isUploading } > - { - setTargetItemId( attachment.id as number ); - open(); - } } - label={ __( 'Replace' ) } - showTooltip - onFilesDrop={ onFilesDrop } - attachment={ attachment } - isUploading={ isUploading } - > -
- - { ( ! isBlob || hasPreviewImage ) && ( - + + { ( ! isBlob || hasPreviewImage ) && ( + + ) } + { ! isBlob && + ( ! hasPreviewImage ? ( + + } /> - ) } - { ! isBlob && - ( ! hasPreviewImage ? ( - - } - /> - ) : ( -
-
- - } - /> -
+ ) : ( +
+
+ + } + />
- ) ) } - -
- - { ! isBlob && ( -
- - { multiple && - allItems && - allItems.length > 1 && ( - - ) } -
+ ) ) } + +
+ + { ! isBlob && ( +
+ + { multiple && + allItems && + allItems.length > 1 && ( + - -
- ) } -
+ } + index={ index } + totalItems={ allItems.length } + isUploading={ isUploading } + moveItem={ moveItem } + orientation="horizontal" + /> + ) } +
+ ) }
); } ) } From cae8022a02c5f05e0dd0eeb101d12cdba5bb8877 Mon Sep 17 00:00:00 2001 From: ntsekouras Date: Tue, 10 Feb 2026 16:43:30 +0200 Subject: [PATCH 13/30] fix focus styles --- packages/fields/src/components/media-edit/style.scss | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/fields/src/components/media-edit/style.scss b/packages/fields/src/components/media-edit/style.scss index 2ef0270356071d..47ba74cb9d87d4 100644 --- a/packages/fields/src/components/media-edit/style.scss +++ b/packages/fields/src/components/media-edit/style.scss @@ -39,6 +39,10 @@ fieldset.fields__media-edit { .fields__media-edit-picker-button { border: 0; border-radius: 0; + + &:focus-visible { + box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color); + } } // Target AnimatedMediaItem wrapper divs (direct children of VStack) From fb0815926d3926bd01727ce34dd9d8aa964c7574 Mon Sep 17 00:00:00 2001 From: James Koster Date: Tue, 10 Feb 2026 16:13:17 +0000 Subject: [PATCH 14/30] control spacing --- packages/fields/src/components/media-edit/index.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/fields/src/components/media-edit/index.tsx b/packages/fields/src/components/media-edit/index.tsx index 725b74c45ff9cf..1f871d6a693b8f 100644 --- a/packages/fields/src/components/media-edit/index.tsx +++ b/packages/fields/src/components/media-edit/index.tsx @@ -867,7 +867,10 @@ export default function MediaEdit< Item >( { { field.label } ) : ( - + { field.label } ) ) } From ae1b58e581eef03b90fbf8067f3d9435c52bd0fd Mon Sep 17 00:00:00 2001 From: James Koster Date: Tue, 10 Feb 2026 16:22:35 +0000 Subject: [PATCH 15/30] compact group styling --- packages/fields/src/components/media-edit/index.tsx | 2 +- packages/fields/src/components/media-edit/style.scss | 11 ++++------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/packages/fields/src/components/media-edit/index.tsx b/packages/fields/src/components/media-edit/index.tsx index 1f871d6a693b8f..4361e329715356 100644 --- a/packages/fields/src/components/media-edit/index.tsx +++ b/packages/fields/src/components/media-edit/index.tsx @@ -494,7 +494,7 @@ function CompactMediaEditAttachments( { { ! isBlob && ( diff --git a/packages/fields/src/components/media-edit/style.scss b/packages/fields/src/components/media-edit/style.scss index 47ba74cb9d87d4..6e0661152890f0 100644 --- a/packages/fields/src/components/media-edit/style.scss +++ b/packages/fields/src/components/media-edit/style.scss @@ -33,7 +33,7 @@ fieldset.fields__media-edit { .fields__media-edit-compact-group { border: $border-width dashed $gray-600; - border-radius: $radius-x-small; + border-radius: $radius-small; overflow: hidden; .fields__media-edit-picker-button { @@ -47,7 +47,7 @@ fieldset.fields__media-edit { // Target AnimatedMediaItem wrapper divs (direct children of VStack) > div > .fields__media-edit-compact:not(:last-child) { - border-bottom: $border-width solid $gray-300; + border-bottom: $border-width solid $gray-100; } } @@ -71,6 +71,7 @@ fieldset.fields__media-edit { opacity: 0; pointer-events: none; z-index: 1; + @include preview-overlay; @media not (prefers-reduced-motion) { transition: opacity 50ms ease-out; @@ -79,10 +80,6 @@ fieldset.fields__media-edit { * { pointer-events: auto; } - - button { - @include preview-overlay; - } } } @@ -103,7 +100,7 @@ fieldset.fields__media-edit { min-width: 0; &:hover { - background-color: $gray-100; + color: var(--wp-admin-theme-color); } &:focus-visible { From 7fee826309eb0b5d4d40f4ad0e05a7b3e7af637e Mon Sep 17 00:00:00 2001 From: James Koster Date: Tue, 10 Feb 2026 16:31:11 +0000 Subject: [PATCH 16/30] expanded group styling --- .../src/components/media-edit/index.tsx | 2 +- .../src/components/media-edit/style.scss | 20 ++++++++----------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/packages/fields/src/components/media-edit/index.tsx b/packages/fields/src/components/media-edit/index.tsx index 4361e329715356..86baba0fa14f14 100644 --- a/packages/fields/src/components/media-edit/index.tsx +++ b/packages/fields/src/components/media-edit/index.tsx @@ -384,7 +384,7 @@ function ExpandedMediaEditAttachments( {
diff --git a/packages/fields/src/components/media-edit/style.scss b/packages/fields/src/components/media-edit/style.scss index 6e0661152890f0..58cc9b6e4333e3 100644 --- a/packages/fields/src/components/media-edit/style.scss +++ b/packages/fields/src/components/media-edit/style.scss @@ -2,7 +2,7 @@ @use "@wordpress/base-styles/variables" as *; @mixin preview-overlay { - border-radius: $radius-x-small; + border-radius: $radius-small; backdrop-filter: blur(16px) saturate(180%); background: rgba(255, 255, 255, 0.75); } @@ -94,7 +94,7 @@ fieldset.fields__media-edit { align-items: center; gap: $grid-unit-15; border: $border-width dashed $gray-600; - border-radius: $radius-x-small; + border-radius: $radius-medium; padding: calc(8px - #{$border-width}); cursor: pointer; min-width: 0; @@ -186,20 +186,16 @@ fieldset.fields__media-edit { .fields__media-edit-expanded-actions { position: absolute; - top: $grid-unit-10; - right: $grid-unit-10; - - button { - @include preview-overlay; - } + top: $grid-unit-05; + right: $grid-unit-05; + @include preview-overlay; } .fields__media-edit-expanded-title { position: absolute; - bottom: 0; - left: 0; - right: 0; - margin: $grid-unit-10; + bottom: $grid-unit-05; + left: $grid-unit-05; + right: $grid-unit-05; padding: $grid-unit-05; text-align: center; @include preview-overlay; From ca0bdbe59b6044915fe124714f95a057bc791e98 Mon Sep 17 00:00:00 2001 From: James Koster Date: Tue, 10 Feb 2026 16:45:19 +0000 Subject: [PATCH 17/30] radius --- .../src/components/media-edit/index.tsx | 32 +++++++------------ .../src/components/media-edit/style.scss | 7 +++- 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/packages/fields/src/components/media-edit/index.tsx b/packages/fields/src/components/media-edit/index.tsx index 86baba0fa14f14..a0d45186f491c2 100644 --- a/packages/fields/src/components/media-edit/index.tsx +++ b/packages/fields/src/components/media-edit/index.tsx @@ -29,7 +29,7 @@ import { useRef, useState, } from '@wordpress/element'; -import { __ } from '@wordpress/i18n'; +import { __, sprintf } from '@wordpress/i18n'; import { archive, audio, @@ -341,7 +341,17 @@ function ExpandedMediaEditAttachments( { setTargetItemId( attachment.id as number ); open(); } } - label={ __( 'Replace' ) } + label={ + ! isBlob + ? sprintf( + /* translators: %s: The title of the media item. */ + __( 'Replace %s' ), + ( + attachment as Attachment< 'view' > + ).title.rendered + ) + : __( 'Replace' ) + } showTooltip onFilesDrop={ onFilesDrop } attachment={ attachment } @@ -359,24 +369,6 @@ function ExpandedMediaEditAttachments( { attachment={ attachment } /> ) } - { ! isBlob && - ( ! hasPreviewImage ? ( - - } - /> - ) : ( -
-
- - } - /> -
-
- ) ) }
diff --git a/packages/fields/src/components/media-edit/style.scss b/packages/fields/src/components/media-edit/style.scss index 58cc9b6e4333e3..9a6232ea806dfd 100644 --- a/packages/fields/src/components/media-edit/style.scss +++ b/packages/fields/src/components/media-edit/style.scss @@ -33,7 +33,7 @@ fieldset.fields__media-edit { .fields__media-edit-compact-group { border: $border-width dashed $gray-600; - border-radius: $radius-small; + border-radius: $radius-medium; overflow: hidden; .fields__media-edit-picker-button { @@ -56,6 +56,10 @@ fieldset.fields__media-edit { position: relative; min-width: 0; + .fields__media-edit-picker-button { + border-radius: $radius-small; + } + &:hover, &:focus-within { .fields__media-edit-compact-movers { @@ -86,6 +90,7 @@ fieldset.fields__media-edit { // Apply to placeholders outside of expanded view (compact contexts) .fields__media-edit-picker-button:has(.fields__media-edit-placeholder):not(.fields__media-edit-expanded *) { @include compact-drop-zone-label; + border-radius: $radius-small; } .fields__media-edit-picker-button { From 4958f01b54e71ab737da4de76b9b8aa9a84a2786 Mon Sep 17 00:00:00 2001 From: James Koster Date: Tue, 10 Feb 2026 17:02:03 +0000 Subject: [PATCH 18/30] tooltip positioning --- packages/fields/src/components/media-edit/index.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/fields/src/components/media-edit/index.tsx b/packages/fields/src/components/media-edit/index.tsx index a0d45186f491c2..720fb39355d196 100644 --- a/packages/fields/src/components/media-edit/index.tsx +++ b/packages/fields/src/components/media-edit/index.tsx @@ -190,7 +190,11 @@ function MediaPickerButton( { if ( ! showTooltip ) { return mediaPickerButton; } - return { mediaPickerButton }; + return ( + + { mediaPickerButton } + + ); } const archiveMimeTypes = [ @@ -250,6 +254,7 @@ function MoveButtons( { size="small" disabled={ isUploading || index === 0 } accessibleWhenDisabled + tooltipPosition="top" onClick={ ( event: React.MouseEvent< HTMLButtonElement > ) => { event.stopPropagation(); moveItem( itemId, 'up' ); @@ -262,6 +267,7 @@ function MoveButtons( { size="small" disabled={ isUploading || index === totalItems - 1 } accessibleWhenDisabled + tooltipPosition="top" onClick={ ( event: React.MouseEvent< HTMLButtonElement > ) => { event.stopPropagation(); moveItem( itemId, 'down' ); @@ -401,6 +407,7 @@ function ExpandedMediaEditAttachments( { size="small" disabled={ isUploading } accessibleWhenDisabled + tooltipPosition="top" onClick={ ( event: React.MouseEvent< HTMLButtonElement > ) => { @@ -511,6 +518,7 @@ function CompactMediaEditAttachments( { size="small" disabled={ isUploading } accessibleWhenDisabled + tooltipPosition="top" onClick={ ( event: React.MouseEvent< HTMLButtonElement > ) => { From b48a6390dcd7b1b6a7f72b3401e3bad0fc52919a Mon Sep 17 00:00:00 2001 From: ntsekouras Date: Wed, 11 Feb 2026 08:33:42 +0200 Subject: [PATCH 19/30] remove orphaned CSS --- packages/fields/src/components/media-edit/style.scss | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/packages/fields/src/components/media-edit/style.scss b/packages/fields/src/components/media-edit/style.scss index 9a6232ea806dfd..70f8136539e3c3 100644 --- a/packages/fields/src/components/media-edit/style.scss +++ b/packages/fields/src/components/media-edit/style.scss @@ -196,16 +196,6 @@ fieldset.fields__media-edit { @include preview-overlay; } - .fields__media-edit-expanded-title { - position: absolute; - bottom: $grid-unit-05; - left: $grid-unit-05; - right: $grid-unit-05; - padding: $grid-unit-05; - text-align: center; - @include preview-overlay; - } - .fields__media-edit-expanded-item { position: relative; min-width: 0; From 5170897fccda67d6af7423510b0fbc43662a99ac Mon Sep 17 00:00:00 2001 From: ntsekouras Date: Wed, 11 Feb 2026 09:11:27 +0200 Subject: [PATCH 20/30] feedback --- .../src/components/media-edit/index.tsx | 53 ++++++++----------- .../src/components/media-edit/style.scss | 3 +- .../media-edit/use-moving-animation.ts | 2 - 3 files changed, 23 insertions(+), 35 deletions(-) diff --git a/packages/fields/src/components/media-edit/index.tsx b/packages/fields/src/components/media-edit/index.tsx index 720fb39355d196..80aa8876a945e4 100644 --- a/packages/fields/src/components/media-edit/index.tsx +++ b/packages/fields/src/components/media-edit/index.tsx @@ -334,6 +334,7 @@ function ExpandedMediaEditAttachments( { const hasPreviewImage = attachment.mime_type?.startsWith( 'image' ); const isBlob = isBlobURL( attachment.source_url ); + const attachmentNumericId = attachment.id as number; return ( { - setTargetItemId( attachment.id as number ); + setTargetItemId( attachmentNumericId ); open(); } } label={ @@ -386,20 +387,16 @@ function ExpandedMediaEditAttachments( { alignment="flex-end" expanded={ false } > - { multiple && - allItems && - allItems.length > 1 && ( - - ) } + { multiple && allItems.length > 1 && ( + + ) }