diff --git a/android/src/main/java/com/reactnativekeyboardcontroller/extensions/EditText.kt b/android/src/main/java/com/reactnativekeyboardcontroller/extensions/EditText.kt index d8d5c6748..d46fb8090 100644 --- a/android/src/main/java/com/reactnativekeyboardcontroller/extensions/EditText.kt +++ b/android/src/main/java/com/reactnativekeyboardcontroller/extensions/EditText.kt @@ -161,18 +161,18 @@ class KeyboardControllerSelectionWatcher( val end = editText.selectionEnd val editTextHeight = editText.height + val view = editText + val layout = view.layout + + if (layout === null) { + return true + } + if (lastSelectionStart != start || lastSelectionEnd != end || lastEditTextHeight != editTextHeight) { lastSelectionStart = start lastSelectionEnd = end lastEditTextHeight = editTextHeight - val view = editText - val layout = view.layout - - if (layout === null) { - return true - } - val cursorPositionStartX: Float val cursorPositionStartY: Float val cursorPositionEndX: Float @@ -226,9 +226,6 @@ class KeyboardControllerSelectionWatcher( fun setup() { editText.viewTreeObserver.addOnPreDrawListener(preDrawListener) - - // trigger initial event (on input switching) - preDrawListener.onPreDraw() } fun destroy() {