@@ -216,15 +216,25 @@ private extension ProductImagesViewController {
216216 return
217217 }
218218 uploadMediaAssetToSiteMediaLibrary ( asset: asset)
219+ // Commits product image changes automatically.
220+ doneButtonTapped ( )
219221 }
220222}
221223
222224// MARK: Action handling for device media library picker
223225//
224226private extension ProductImagesViewController {
225227 func onDeviceMediaLibraryPickerCompletion( assets: [ PHAsset ] ) {
228+ let shouldCommitChanges = assets. isNotEmpty
226229 defer {
227- dismiss ( animated: true , completion: nil )
230+ dismiss ( animated: !shouldCommitChanges) { [ weak self] in
231+ guard shouldCommitChanges else {
232+ return
233+ }
234+
235+ // Commits product image changes automatically.
236+ self ? . doneButtonTapped ( )
237+ }
228238 }
229239 guard assets. isEmpty == false else {
230240 return
@@ -239,7 +249,15 @@ private extension ProductImagesViewController {
239249//
240250private extension ProductImagesViewController {
241251 func onWPMediaPickerCompletion( mediaItems: [ Media ] ) {
242- dismiss ( animated: true , completion: nil )
252+ let shouldCommitChanges = mediaItems. isNotEmpty
253+ dismiss ( animated: !shouldCommitChanges) { [ weak self] in
254+ guard shouldCommitChanges else {
255+ return
256+ }
257+
258+ // Commits product image changes automatically.
259+ self ? . doneButtonTapped ( )
260+ }
243261 productImageActionHandler. addSiteMediaLibraryImagesToProduct ( mediaItems: mediaItems)
244262 }
245263}
0 commit comments