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
- VFX Graph Documentation dropdown button does nothing when clicked on the right side
- Required SpriteMask class (ID 331) is stripped when "Strip Engine Code" is enabled
- “Maximized serialized file backup not found” error is thrown when minimizing a window in a newly opened project
- Build stack trace contains invalid lines when building with IL2CPP using scripts with delegates containing generic types in the signature
- Entities Systems window has a “Show Full Player Loop” dropdown which does nothing when clicked after enabling “Show Full Player Loop”
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;
}
}