Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(mobile): the composer stays one row until the draft wraps #20812

Mergedjuliusmarmingemerged 10 commits intomain fromrefs/pull/20812/headmerged by juliusmarminge View on GitHub

Showing 22 changed files with 12 additions and 4 deletions (loading 18).

x
0 of 22 viewed, 22 left
0 additions and 0 deletionsapps/mobile/deps/react-native-screens-5.0.0-t3.29.tgzDeleted

Binary file not shown.

0 additions and 0 deletionsapps/mobile/deps/react-native-screens-5.0.0-t3.30.tgzAdded
View file

Binary file not shown.

12 additions and 4 deletionsapps/mobile/modules/t3-composer-editor/android/src/main/java/expo/modules/t3composereditor/T3ComposerEditorView.ktModified
View file
@@ -57,6 +57,7 @@
private var applyingNativeValue = false
private var desiredLineHeightPx = 0
private var lastContentHeight = 0
+ private var lastContentWidth = 0
private var contentInsetVertical = 0
private var tokensJson = "[]"
private var tokens: List<ComposerToken> = emptyList()
@@ -424,12 +425,19 @@
​
private fun emitContentSizeIfNeeded() {
- val height = editor.layout?.height ?: editor.measuredHeight
- val contentHeight = height + contentInsetVertical * 2
- if (contentHeight == lastContentHeight) return
+ // The laid-out text without insets. A one-line draft reports its natural width, so
+ // JS can tell whether it fits a narrower row than the one it is laid out in; past
+ // one line only the height matters. Trailing whitespace hangs past a line without
+ // wrapping it, so getLineMax leaves it out.
+ val layout = editor.layout
+ val contentHeight = layout?.height ?: editor.measuredHeight
+ val contentWidth = if (layout?.lineCount == 1) layout.getLineMax(0).toInt() else 0
+ if (contentHeight == lastContentHeight && contentWidth == lastContentWidth) return