Skip to content

Commit 0e0add0

Browse files
committed
Gutenberg: Bypass selection change events until re-enabled
1 parent c83d232 commit 0e0add0

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

aztec/src/main/kotlin/org/wordpress/aztec/AztecText.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
246246
var commentsVisible = resources.getBoolean(R.bool.comments_visible)
247247

248248
var isInCalypsoMode = true
249+
var isInGutenbergMode = false
249250

250251
var consumeHistoryEvent: Boolean = false
251252

@@ -343,6 +344,10 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
343344
isInCalypsoMode = isCompatibleWithCalypso
344345
}
345346

347+
fun setGutenbergMode(isCompatibleWithGutenberg: Boolean) {
348+
isInGutenbergMode = isCompatibleWithGutenberg
349+
}
350+
346351
@SuppressLint("ResourceType")
347352
private fun init(attrs: AttributeSet?) {
348353
disableTextChangedListener()
@@ -860,6 +865,10 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
860865
if (!isViewInitialized) return
861866

862867
if (isOnSelectionListenerDisabled()) {
868+
if (isInGutenbergMode) {
869+
return
870+
}
871+
863872
enableOnSelectionListener()
864873
return
865874
}

0 commit comments

Comments
 (0)