From ce28deee43c222e6c9ff27da215b24248e371b3a Mon Sep 17 00:00:00 2001 From: Joe Dolson Date: Wed, 12 Apr 2023 23:42:20 +0000 Subject: [PATCH] Media: Render attachment custom fields for new uploads. Initialize attachment custom fields during the `add` callback, so that fields are present as soon as an attachment is uploaded but do not refresh when field values are changed. Follow up to #40909. Props trepmal, adamsilverstein, joedolson. Fixes #58051. git-svn-id: https://develop.svn.wordpress.org/trunk@55649 602fd350-edb4-49c9-b593-d223f7449a82 --- src/js/media/views/attachment-compat.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/js/media/views/attachment-compat.js b/src/js/media/views/attachment-compat.js index c0106bb8df..d24de56963 100644 --- a/src/js/media/views/attachment-compat.js +++ b/src/js/media/views/attachment-compat.js @@ -24,6 +24,11 @@ AttachmentCompat = View.extend(/** @lends wp.media.view.AttachmentCompat.prototy 'change textarea': 'save' }, + initialize: function() { + // Render the view when a new item is added. + this.listenTo( this.model, 'add', this.render ); + }, + /** * @return {wp.media.view.AttachmentCompat} Returns itself to allow chaining. */