https://kotlinlang.org logo
#compose
Title
# compose
r

Rooparsh

05/31/2021, 2:54 PM
Hi all, I have been trying my hands on Compose recently and stumbled upon
TextField
API. I noticed some issue in the one of the API approach. The cursor doesn't move forward as the value gets updated. Attaching a video as reference. Its the one which accepts TextFieldValue Am I missing here something ??
🧵 1
🧵 1
c

Colton Idle

05/31/2021, 2:56 PM
@Rooparsh do you think you can edit your post to match these guidelines? https://kotlinlang.slack.com/archives/CJLTWPH7S/p1616265877303000
👍 1
r

Rooparsh

05/31/2021, 2:57 PM
It has 2 variations, One which accepts value as a String and returns String in high order function.
Copy code
@Composable
fun TextField(
    value: String,
    onValueChange: (String) -> Unit,
    modifier: Modifier = Modifier,
    enabled: Boolean = true,
    readOnly: Boolean = false,
    textStyle: TextStyle = LocalTextStyle.current,
    label: @Composable (() -> Unit)? = null,
    placeholder: @Composable (() -> Unit)? = null,
    leadingIcon: @Composable (() -> Unit)? = null,
    trailingIcon: @Composable (() -> Unit)? = null,
    isError: Boolean = false,
    visualTransformation: VisualTransformation = VisualTransformation.None,
    keyboardOptions: KeyboardOptions = KeyboardOptions.Default,
    keyboardActions: KeyboardActions = KeyboardActions(),
    singleLine: Boolean = false,
    maxLines: Int = Int.MAX_VALUE,
    interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
    shape: Shape =
        MaterialTheme.shapes.small.copy(bottomEnd = ZeroCornerSize, bottomStart = ZeroCornerSize),
    colors: TextFieldColors = TextFieldDefaults.textFieldColors()
) {
👍 1
The second being, which accepts TextFieldValue and returns TextFieldValue in high order function.
Copy code
@Composable
fun TextField(
    value: TextFieldValue,
    onValueChange: (TextFieldValue) -> Unit,
    modifier: Modifier = Modifier,
    enabled: Boolean = true,
    readOnly: Boolean = false,
    textStyle: TextStyle = LocalTextStyle.current,
    label: @Composable (() -> Unit)? = null,
    placeholder: @Composable (() -> Unit)? = null,
    leadingIcon: @Composable (() -> Unit)? = null,
    trailingIcon: @Composable (() -> Unit)? = null,
    isError: Boolean = false,
    visualTransformation: VisualTransformation = VisualTransformation.None,
    keyboardOptions: KeyboardOptions = KeyboardOptions.Default,
    keyboardActions: KeyboardActions = KeyboardActions(),
    singleLine: Boolean = false,
    maxLines: Int = Int.MAX_VALUE,
    interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
    shape: Shape =
        MaterialTheme.shapes.small.copy(bottomEnd = ZeroCornerSize, bottomStart = ZeroCornerSize),
    colors: TextFieldColors = TextFieldDefaults.textFieldColors()
) {
c

Colton Idle

05/31/2021, 2:59 PM
@Rooparsh have you tried on a physical device? I've seen weirdness like this on an emulator, but never my physical device.
r

Rooparsh

05/31/2021, 3:00 PM
Yes, tried on multiple devices. Facing this issue only with TextFieldValue API. The String one is working fine.
@Colton Idle I am using
1.0.0-beta07
compose version.
@Ian Lake can you share your insights in this?
c

Colton Idle

06/03/2021, 1:46 PM
This seems pretty important though so I would file a bug with a reproducible sample if possible to get some eyes on it.
r

Rooparsh

06/04/2021, 4:42 AM