From 18d6028ff908eef99aae363d8ee9a6789d264284 Mon Sep 17 00:00:00 2001 From: "kunal.chavhan" Date: Fri, 12 Jul 2024 10:49:54 -0700 Subject: [PATCH] fix: select text on auto focus for TextInput (#45004) Summary: Fixes: https://github.com/facebook/react-native/issues/43413 This pull request addresses an issue on Android where the text selection was not working when both `selectTextOnFocus` and `autoFocus` were set to true on TextInput. `ReactTextInputManager` was calling `setSelectAllOnFocus` on `ReactEditText` before its onLayout is called causing text selection to not work on auto focus. Changes Made - Added logic to wait for the ReactEditText view's layout to be drawn before attempting to select the text. On the first layout pass, the code now explicitly calls selectAll() to select the text. - Implemented a check to ensure selectAll() is only called during the first layout pass, avoiding unnecessary calls on subsequent layout passes. Impact This change ensures that text selection is properly triggered when selectTextOnFocus and autoFocus are both enabled, improving the user experience and making text input behavior consistent and reliable. ## Changelog: [ANDROID] [FIXED]: fixed select text on auto focus for TextInput