From 91c0d91054584adc1d33fd04638765dafd1e3072 Mon Sep 17 00:00:00 2001 From: thesharifdev Date: Wed, 12 Jul 2023 22:17:54 +0600 Subject: [PATCH 1/4] fixed media-not-getting-removed-from-the media library popup after clicking "Delete permanently" button --- src/js/media/models/attachment.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/js/media/models/attachment.js b/src/js/media/models/attachment.js index 267624b7d6c48..d497cfe2c6c23 100644 --- a/src/js/media/models/attachment.js +++ b/src/js/media/models/attachment.js @@ -83,6 +83,12 @@ Attachment = Backbone.Model.extend(/** @lends wp.media.model.Attachment.prototyp }); return wp.media.ajax( options ).done( function() { + + //get the element which contains the deleted data-id + deletedAttached = document.querySelector('li[data-id="' + this.id + '"]'); + if(deletedAttached){ + deletedAttached.remove(); + } this.destroyed = true; }).fail( function() { this.destroyed = false; From 996d194089bfd6ced2769198516738439e5e6b15 Mon Sep 17 00:00:00 2001 From: thesharifdev Date: Wed, 12 Jul 2023 22:33:04 +0600 Subject: [PATCH 2/4] corrected mistake for variable --- src/js/media/models/attachment.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/media/models/attachment.js b/src/js/media/models/attachment.js index d497cfe2c6c23..b1fd66186b96c 100644 --- a/src/js/media/models/attachment.js +++ b/src/js/media/models/attachment.js @@ -85,7 +85,7 @@ Attachment = Backbone.Model.extend(/** @lends wp.media.model.Attachment.prototyp return wp.media.ajax( options ).done( function() { //get the element which contains the deleted data-id - deletedAttached = document.querySelector('li[data-id="' + this.id + '"]'); + var deletedAttached = document.querySelector('li[data-id="' + this.id + '"]'); if(deletedAttached){ deletedAttached.remove(); } From 788d0c793b877b4be0ceeafb51594e50c496aa35 Mon Sep 17 00:00:00 2001 From: thesharifdev Date: Wed, 12 Jul 2023 22:54:06 +0600 Subject: [PATCH 3/4] scrip_debug test issue fixed --- src/js/media/models/attachment.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/js/media/models/attachment.js b/src/js/media/models/attachment.js index b1fd66186b96c..a3feb3c89557a 100644 --- a/src/js/media/models/attachment.js +++ b/src/js/media/models/attachment.js @@ -84,10 +84,10 @@ Attachment = Backbone.Model.extend(/** @lends wp.media.model.Attachment.prototyp return wp.media.ajax( options ).done( function() { - //get the element which contains the deleted data-id + // Get the element which contains the deleted data-id var deletedAttached = document.querySelector('li[data-id="' + this.id + '"]'); - if(deletedAttached){ - deletedAttached.remove(); + if (deletedAttached !== null) { + deletedAttached.parentNode.removeChild(deletedAttached); } this.destroyed = true; }).fail( function() { From 3bc6dd1200986c00f6545296dc8ec981798c2094 Mon Sep 17 00:00:00 2001 From: thesharifdev Date: Wed, 12 Jul 2023 23:08:17 +0600 Subject: [PATCH 4/4] console error fixed --- src/js/media/models/attachment.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/js/media/models/attachment.js b/src/js/media/models/attachment.js index a3feb3c89557a..45a8ce72fe186 100644 --- a/src/js/media/models/attachment.js +++ b/src/js/media/models/attachment.js @@ -86,8 +86,8 @@ Attachment = Backbone.Model.extend(/** @lends wp.media.model.Attachment.prototyp // Get the element which contains the deleted data-id var deletedAttached = document.querySelector('li[data-id="' + this.id + '"]'); - if (deletedAttached !== null) { - deletedAttached.parentNode.removeChild(deletedAttached); + if(deletedAttached){ + deletedAttached.remove(); } this.destroyed = true; }).fail( function() {