Skip to content

Commit

Permalink
Merge pull request #20657 from wordpress-mobile/gutenberg/fix/prevent…
Browse files Browse the repository at this point in the history
…-editor-update-on-closing

[Gutenberg] Avoid sending HTML to the editor when closing
  • Loading branch information
fluiddot authored May 12, 2023
2 parents e789938 + 3fb86e0 commit 647f5ff
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ class GutenbergViewController: UIViewController, PostEditor, FeaturedImageDelega

var postIsReblogged: Bool = false

var isEditorClosing: Bool = false

// MARK: - Editor Media actions

var isUploadingMedia: Bool {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -912,6 +919,7 @@ extension GutenbergViewController: GutenbergBridgeDelegate {
showAlertForEmptyPostPublish()
}
case .close:
isEditorClosing = true
cancelEditing()
case .more:
displayMoreSheet()
Expand Down

0 comments on commit 647f5ff

Please sign in to comment.