From d659dc14661cf6ff5a61be07cdb4009008bdc02e Mon Sep 17 00:00:00 2001 From: dhruvang21 Date: Tue, 15 Jul 2025 10:43:21 +0530 Subject: [PATCH 1/2] Fix: image caption disappears --- src/js/media/views/attachments.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/js/media/views/attachments.js b/src/js/media/views/attachments.js index b2e91624cb159..7956dd6c03b6f 100644 --- a/src/js/media/views/attachments.js +++ b/src/js/media/views/attachments.js @@ -293,7 +293,13 @@ Attachments = View.extend(/** @lends wp.media.view.Attachments.prototype */{ // Record the initial `index` of the dragged model. start: function( event, ui ) { - ui.item.data('sortableIndexStart', ui.item.index()); + /* + * Ensure that any caption that currently has focus and has potentially been changed + * is saved before the media is reordered, which would reset the caption. + */ + $( 'input.describe:focus').trigger( 'change' ); + + ui.item.data('sortableIndexStart', ui.item.index()); }, /* From a542d5df7339c320ee5da6e6d933d7cc8dc7314b Mon Sep 17 00:00:00 2001 From: dhruvang21 <105810308+dhruvang21@users.noreply.github.com> Date: Wed, 16 Jul 2025 09:37:16 +0530 Subject: [PATCH 2/2] Update indentation Co-authored-by: Mukesh Panchal --- src/js/media/views/attachments.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/js/media/views/attachments.js b/src/js/media/views/attachments.js index 7956dd6c03b6f..ff4d095d8f839 100644 --- a/src/js/media/views/attachments.js +++ b/src/js/media/views/attachments.js @@ -293,13 +293,13 @@ Attachments = View.extend(/** @lends wp.media.view.Attachments.prototype */{ // Record the initial `index` of the dragged model. start: function( event, ui ) { - /* - * Ensure that any caption that currently has focus and has potentially been changed - * is saved before the media is reordered, which would reset the caption. - */ - $( 'input.describe:focus').trigger( 'change' ); + /* + * Ensure that any caption that currently has focus and has potentially been changed + * is saved before the media is reordered, which would reset the caption. + */ + $( 'input.describe:focus').trigger( 'change' ); - ui.item.data('sortableIndexStart', ui.item.index()); + ui.item.data('sortableIndexStart', ui.item.index()); }, /*