Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,8 @@ public open class ReactEditText public constructor(context: Context) : AppCompat
}
wasMultiline = isMultiline

updatePlaceholderEllipsize()

// We override the KeyListener so that all keys on the soft input keyboard as well as hardware
// keyboards work. Some KeyListeners like DigitsKeyListener will display the keyboard but not
// accept all input from it
Expand All @@ -606,6 +608,16 @@ public open class ReactEditText public constructor(context: Context) : AppCompat
this.placeholder = placeholder
hint = placeholder
}
updatePlaceholderEllipsize()
}

private fun updatePlaceholderEllipsize() {
ellipsize =
if (!isMultiline) {
TextUtils.TruncateAt.END
} else {
null
}
}

public fun setFontFamily(fontFamily: String?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import android.text.InputType
import android.text.Layout
import android.text.SpannableString
import android.text.Spanned
import android.text.TextUtils
import android.util.DisplayMetrics
import android.view.Gravity
import android.view.View
Expand Down Expand Up @@ -196,9 +197,25 @@ class ReactTextInputPropertyTest {

manager.updateProperties(view, buildStyles("placeholder", "sometext"))
assertThat(view.hint).isEqualTo("sometext")
assertThat(view.ellipsize).isEqualTo(TextUtils.TruncateAt.END)

manager.updateProperties(view, buildStyles("placeholder", null))
assertThat(view.hint).isNull()
assertThat(view.ellipsize).isEqualTo(TextUtils.TruncateAt.END)
}

@Test
fun testPlaceholderEllipsizeRespectsMultiline() {
manager.updateProperties(view, buildStyles("placeholder", "a very long placeholder string"))
assertThat(view.ellipsize).isEqualTo(TextUtils.TruncateAt.END)

manager.updateProperties(view, buildStyles("multiline", true))
view.commitStagedInputType()
assertThat(view.ellipsize).isNull()

manager.updateProperties(view, buildStyles("multiline", false))
view.commitStagedInputType()
assertThat(view.ellipsize).isEqualTo(TextUtils.TruncateAt.END)
}

@Test
Expand Down
Loading