Skip to content
Open
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 @@ -258,6 +258,13 @@ public open class ReactEditText public constructor(context: Context) : AppCompat
if (contextMenuHidden) {
return false
}
// setTextIsSelectable(true) (see onAttachedToWindow) makes the platform Editor
// treat this view as read-only selectable text and skip its "Show the IME to be
// able to replace text" branch when a selection or insertion action mode starts
// (Editor#startActionModeInternal gates it on !isTextSelectable()). Compensate
// here so long-pressing an editable input summons the keyboard, matching stock
// EditText behavior.
showSoftKeyboardIfEditable()
menu.removeItem(android.R.id.pasteAsPlainText)
return true
}
Expand Down Expand Up @@ -499,6 +506,14 @@ public open class ReactEditText public constructor(context: Context) : AppCompat
if (focused && selectionWatcher != null) {
selectionWatcher?.onSelectionChanged(selectionStart, selectionEnd)
}
// Gaining focus with a non-collapsed selection means focus arrived through a
// long-press text selection rather than a tap or programmatic focus — the one focus
// path that never requests the soft keyboard (see onCreateActionMode). The action
// mode can be created before this view becomes the IME-served view, so request the
// keyboard again now that focus has landed.
if (focused && hasSelection()) {
showSoftKeyboardIfEditable()
}
}

internal fun setSelectionWatcher(selectionWatcher: SelectionWatcher?) {
Expand Down Expand Up @@ -909,6 +924,14 @@ public open class ReactEditText public constructor(context: Context) : AppCompat

protected fun showSoftKeyboard(): Boolean = inputMethodManager.showSoftInput(this, 0)

// Mirrors the guard on requestFocusProgrammatically(), plus editability ("editable"
// prop maps to isEnabled): never summon the keyboard for a read-only input.
private fun showSoftKeyboardIfEditable() {
if (isEnabled && isInTouchMode && showSoftInputOnFocus) {
showSoftKeyboard()
}
}

protected fun hideSoftKeyboard() {
inputMethodManager.hideSoftInputFromWindow(windowToken, 0)
}
Expand Down