Thread
#compose
    Ian Warwick

    Ian Warwick

    2 years ago
    Hey folks, got this issue where I compose some UI based on a model which shows either
    TextInput
    or
    Text
    when I double click on the text it turns the
    Text
    into a
    TextInput
    in the compose tree
    @Composable
    private fun Text(
        element: TextElement,
        inEdit: Boolean = false
    ) {
        val textStyle = TextStyle(
            background = Color.Transparent,
            fontWeight = element.fontWeight,
            fontSize = TextUnit.Em(element.fontSize),
            color = element.color
        )
    
        val spacing =
            Spacing(element.spacingLeft.dp, element.spacingTop.dp, element.spacingRight.dp, element.spacingBottom.dp)
    
        if (inEdit) {
            TextField(modifier = spacing, value = element.text, textStyle = textStyle, onValueChange = {
                element.text = it
            })
        } else {
            Text(modifier = spacing, text = element.text, style = textStyle)
        }
    }
    It seems that even though
    Text
    is being displayed Compose is still receiving text input via the missing
    TextInput
    (see video) possibly.. I would expect that if a recompose occurs then it would not exist in this part of the compose graph anymore 🤔 any ideas?
    matvei

    matvei

    2 years ago
    I think it might be worth to file a bug here
    Ian Warwick

    Ian Warwick

    2 years ago
    Cool will file it, tough to explain hopefully i have covered it 🙂
    Thanks @matvei filed one https://issuetracker.google.com/issues/147690622 added a cut down version of the issue as an attachement
    matvei

    matvei

    2 years ago
    Thanks!