From 7b64dc237a9ede5146b3fcbbec68cd0dc751fae6 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sun, 27 Sep 2020 08:48:05 +0000 Subject: [PATCH] Media: Check if the item is defined before setting the `skipHistory` property in media frame router. This avoids a JS error when refreshing the "Attachment details" modal for an item that is not currently queried. Follow-up to [41021]. Props Mista-Flo, mukesh27. Fixes #51395. git-svn-id: https://develop.svn.wordpress.org/trunk@49062 602fd350-edb4-49c9-b593-d223f7449a82 --- src/js/media/routers/manage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/media/routers/manage.js b/src/js/media/routers/manage.js index 7f85f0a474..aabda330ae 100644 --- a/src/js/media/routers/manage.js +++ b/src/js/media/routers/manage.js @@ -43,9 +43,9 @@ var Router = Backbone.Router.extend(/** @lends wp.media.view.MediaFrame.Manage.R // Trigger the media frame to open the correct item. item = library.findWhere( { id: parseInt( query, 10 ) } ); - item.set( 'skipHistory', true ); if ( item ) { + item.set( 'skipHistory', true ); frame.trigger( 'edit:attachment', item ); } else { item = media.attachment( query );