Skip to content

Commit 4a12552

Browse files
Media: disable "Insert Gallery" button during uploads.
Ensure that the button to insert a gallery is disabled until all image uploads have completed on the Edit Gallery screen. Prevents an issue where users could insert a gallery with some images missing. Props: adamsilverstein, gonom9, rishavdutta. Fixes: #39824. git-svn-id: https://develop.svn.wordpress.org/trunk@60031 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 6f9d8e6 commit 4a12552

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

src/js/media/views/frame/post.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ Post = Select.extend(/** @lends wp.media.view.MediaFrame.Post.prototype */{
580580
style: 'primary',
581581
text: editing ? l10n.updateGallery : l10n.insertGallery,
582582
priority: 80,
583-
requires: { library: true },
583+
requires: { library: true, uploadingComplete: true },
584584

585585
/**
586586
* @fires wp.media.controller.State#update

src/js/media/views/toolbar.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,18 @@ Toolbar = View.extend(/** @lends wp.media.view.Toolbar.prototype */{
143143
}
144144

145145
var requires = button.options.requires,
146-
disabled = false;
146+
disabled = false,
147+
modelsUploading = ! _.isEmpty( library.findWhere( { 'uploading': true } ) );
147148

148149
// Prevent insertion of attachments if any of them are still uploading.
149150
if ( selection && selection.models ) {
150151
disabled = _.some( selection.models, function( attachment ) {
151152
return attachment.get('uploading') === true;
152153
});
153154
}
155+
if ( requires.uploadingComplete && modelsUploading ) {
156+
disabled = true;
157+
}
154158

155159
if ( requires.selection && selection && ! selection.length ) {
156160
disabled = true;

0 commit comments

Comments
 (0)