Search Issue Tracker
By Design
Votes
0
Found in
6000.1.0b7
6000.2.0a4
Issue ID
UUM-98591
Regression
Yes
Cursor stays in front of the first character when entering text in the TextMeshPro field
Reproduction steps:
1. Open the minimal repro “CaretPosition.zip” project
2. Open SampleScene
3. Enter Play Mode
5. Input the text “test” into the text field
6. Observe the Input field
Expected result: The entered text appears in the Input field correctly, displaying “test”
Actual result: After typing, the text displayed in the Input field is “estt”
Reproducible with: 2023.2.0a14, 6000.0.32f1, 6000.1.0a8
Not reproducible with: 2021.3.47f1, 2022.3.55f1, 2023.2.0a13
Reproducible on: Windows 11 and MacOS
Not reproducible on: No other environment tested
Note: The issue may not reproduce on the first attempt
Slack thread: https://unity.slack.com/archives/C5AURAWV7/p1739928022708299
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Error “Shader error in 'YSCloudCover': call to 'tex3D' is ambiguous at Assets/YSCloudCoverText.shader(606) (on d3d11)“ is present when compiling tex3D shader with DXC
- Placeholder asset is not loaded with Advertisement Legacy sample when using the latest version of the package
- Addressables content build fails but the Player build is successful when building a development build
- Out-of-bounds memory access with multiple CanvasRenderers under a Canvas when using Mesh API
- Inspector tries to access file after it was deleted when the file was locked in Inspector window
Resolution Note:
The caretPosition is tied to the generated text, meaning it’s relative to the parsed string— it excludes rich text tags. The onValueChanged callback fires after the string is updated, but before the text generation. This timing supports custom validation and isn’t something we can change.
If you don’t need the parsed string (no rich text tags), I’d recommend using inputField.stringPosition instead. If rich text is involved, I’d recommend updating the caret on the next frame like this:
public class SetCaret : MonoBehaviour
{
private TMP_InputField inputField;
private void Start()
{
inputField = GetComponent<TMP_InputField>();
inputField.onValueChanged.AddListener(_ => StartCoroutine(DelayedCaretSet()));
}
private IEnumerator DelayedCaretSet()
{
yield return null; // Wait for next frame
inputField.caretPosition = inputField.stringPosition;
}
}