Thread
#compose
    Rooparsh

    Rooparsh

    1 year ago
    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 ??
    Colton Idle

    Colton Idle

    1 year ago
    @Rooparsh do you think you can edit your post to match these guidelines? https://kotlinlang.slack.com/archives/CJLTWPH7S/p1616265877303000
    Rooparsh

    Rooparsh

    1 year ago
    It has 2 variations, One which accepts value as a String and returns String in high order function.
    @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()
    ) {
    The second being, which accepts TextFieldValue and returns TextFieldValue in high order function.
    @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()
    ) {
    Colton Idle

    Colton Idle

    1 year ago
    @Rooparsh have you tried on a physical device? I've seen weirdness like this on an emulator, but never my physical device.
    Rooparsh

    Rooparsh

    1 year ago
    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?
    Colton Idle

    Colton Idle

    1 year ago
    This seems pretty important though so I would file a bug with a reproducible sample if possible to get some eyes on it.
    Rooparsh

    Rooparsh

    1 year ago