Cursor is shown at the end of the given value when autoFocus is set to true with a value.
Cursor blinks at the start of the given value
Link: https://codesandbox.io/s/m3339635nj
I'm currently working on a feature that lets users to edit their messages (similar to the example provided) using Material UI's TextField component.
| Tech | Version |
|--------------|---------|
| Material-UI | v1.4.3 |
| React | v16.4.2 |
@Jae-Huh Same behavior with a native input
element.
https://codesandbox.io/s/38vxvq0kwm
You need to get a reference on the input with the inputRef
property and to change the caret position with a DOM API.
x.setSelectionRange(0, 0);
@oliviertassinari If you compare your sandbox with mine on Safari, the difference is that the Material UI Input cursor goes to the start of the input field, and the cursor in the native input goes to the end of the field.
With Material UI Input component:
Native input element:
The behaviour I expect is that the Material UI Input component should have the cursor at the end of the field like the native behaviour.
Oh, my bad. It sounds like an issue with React. We don't have any specific handling for the focus logic.
I would like to draw an attention to this issue one more time because now in 4.9.4 it still exists and stil breaks the expectations (for multiline textfield).
Is it possible to make the Material UI multiline TextField component to have the cursor at the end after autofocus not writing ref-boilerplate for every single one of the them?
Update: it reproduces for multiline textfield.
Most helpful comment
I would like to draw an attention to this issue one more time because now in 4.9.4 it still exists and stil breaks the expectations (for multiline textfield).
Is it possible to make the Material UI multiline TextField component to have the cursor at the end after autofocus not writing ref-boilerplate for every single one of the them?
Update: it reproduces for multiline textfield.