Skip to content

Commit e27df6d

Browse files
authored
Merge pull request #838 from wordpress-mobile/feature/refresh-text-on-layout-size-change
Fix breaking layout on slow window resizing.
2 parents 4aabe35 + 606b1b4 commit e27df6d

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,17 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
452452
isViewInitialized = true
453453
}
454454

455+
override fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int) {
456+
// layout is changing when app screen is resized (on Chromebooks, etc.)
457+
// we need to refresh text to reflect visual changes
458+
if (changed) {
459+
post {
460+
refreshText(false)
461+
}
462+
}
463+
super.onLayout(changed, left, top, right, bottom)
464+
}
465+
455466
// Setup the keyListener(s) for Backspace and Enter key.
456467
// Backspace: If listener does return false we remove the style here
457468
// Enter: Ask the listener if we need to insert or not the char

aztec/src/test/kotlin/org/wordpress/aztec/AztecToolbarTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ class AztecToolbarTest {
648648
@Throws(Exception::class)
649649
fun emptySelection() {
650650
editText.fromHtml("<b>bold</b><b><i>italic</i></b>")
651-
editText.setText("")
651+
editText.fromHtml("", false)
652652

653653
Assert.assertTrue(TestUtils.safeEmpty(editText))
654654

0 commit comments

Comments
 (0)