Skip to content

Commit 213f36e

Browse files
committed
Don't steal focus on initial load of media
1 parent 2178541 commit 213f36e

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,7 +1025,7 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
10251025
private fun replaceImage(drawable: Drawable?) {
10261026
it.drawable = drawable
10271027
post {
1028-
refreshText()
1028+
refreshText(false)
10291029
}
10301030
}
10311031
}
@@ -1058,7 +1058,7 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
10581058
private fun replaceImage(drawable: Drawable?) {
10591059
it.drawable = drawable
10601060
post {
1061-
refreshText()
1061+
refreshText(false)
10621062
}
10631063
}
10641064
}
@@ -1246,10 +1246,16 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
12461246
}
12471247

12481248
open fun refreshText() {
1249+
refreshText(true)
1250+
}
1251+
1252+
open fun refreshText(keepFocus: Boolean) {
12491253
disableTextChangedListener()
12501254
val selStart = selectionStart
12511255
val selEnd = selectionEnd
1252-
setFocusOnParentView()
1256+
if (keepFocus) {
1257+
setFocusOnParentView()
1258+
}
12531259
text = editableText
12541260
setSelection(selStart, selEnd)
12551261
enableTextChangedListener()

0 commit comments

Comments
 (0)