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
- Test Runner’s vertical scrollbar overlaps with the up and down arrows and upper toolbar tabs when the window is minimized
- The Input Field view is not updated when deleting lines of text
- The scrollbar does not respect empty lines in the Input Field
- “Texture Atlas Viewer“ button text overlaps another button when the UI Toolkit Debugger is narrowed
- Thresholds are no longer automatically calculated after deleting Motion fields in Blendtrees
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;
}
}