Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages/media-utils/src/components/media-upload/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -396,10 +396,11 @@ class MediaUpload extends Component {

onClose() {
const { onClose } = this.props;

if ( onClose ) {
onClose();
}

this.isModalOpen = false;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm no Media Library code expert, but I think we should call this.frame.detach() on close action. Otherwise, the modal leaves some "breadcrumbs" in the DOM. Core does a similar thing for classic widgets.

Screenshot

CleanShot 2024-05-29 at 19 37 13

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a longer reply in Slack. TL;DR I agree.

}

updateCollection() {
Expand All @@ -421,6 +422,10 @@ class MediaUpload extends Component {
}

openModal() {
if ( this.isModalOpen ) {
return;
}

const {
allowedTypes,
gallery = false,
Expand Down Expand Up @@ -454,6 +459,7 @@ class MediaUpload extends Component {
}
this.initializeListeners();
this.frame.open();
this.isModalOpen = true;
}

render() {
Expand Down