From 3fb86e04434764fbe9ab15dbcc07bef4975d1efa Mon Sep 17 00:00:00 2001 From: Carlos Garcia Date: Wed, 10 May 2023 12:59:22 +0200 Subject: [PATCH] Avoid sending HTML to the editor when closing it --- .../Gutenberg/GutenbergViewController.swift | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/WordPress/Classes/ViewRelated/Gutenberg/GutenbergViewController.swift b/WordPress/Classes/ViewRelated/Gutenberg/GutenbergViewController.swift index 3a0b1d512882..8983ede2d516 100644 --- a/WordPress/Classes/ViewRelated/Gutenberg/GutenbergViewController.swift +++ b/WordPress/Classes/ViewRelated/Gutenberg/GutenbergViewController.swift @@ -100,6 +100,8 @@ class GutenbergViewController: UIViewController, PostEditor, FeaturedImageDelega var postIsReblogged: Bool = false + var isEditorClosing: Bool = false + // MARK: - Editor Media actions var isUploadingMedia: Bool { @@ -205,7 +207,12 @@ class GutenbergViewController: UIViewController, PostEditor, FeaturedImageDelega } self.html = html - gutenberg.updateHtml(html) + + // Avoid sending the HTML back to the editor if it's closing. + // Otherwise, it will cause the editor to recreate all blocks. + if !isEditorClosing { + gutenberg.updateHtml(html) + } } func getHTML() -> String { @@ -912,6 +919,7 @@ extension GutenbergViewController: GutenbergBridgeDelegate { showAlertForEmptyPostPublish() } case .close: + isEditorClosing = true cancelEditing() case .more: displayMoreSheet()