Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stateful UI content inside capturable() Modifier not updating on UI #140

Closed
ImaginativeShohag opened this issue Jan 31, 2024 · 3 comments · Fixed by #148
Closed

Stateful UI content inside capturable() Modifier not updating on UI #140

ImaginativeShohag opened this issue Jan 31, 2024 · 3 comments · Fixed by #148
Labels
bug Something isn't working

Comments

@ImaginativeShohag
Copy link

The content wrapped with capturable() modifier is not updating.

How to produce?

In MainActivity.kt file, I added a counter in BookingDetail composable:

@Composable
fun BookingDetail() {
    var time by remember { mutableStateOf(Date()) }

    fun formatDateTo12HourClock(date: Date): String {
        val sdf = SimpleDateFormat("hh:mm:ss a", Locale.getDefault())
        return sdf.format(date)
    }

    LaunchedEffect(Unit) {
        while (true) {
            delay(1000)

            time = Date()
        }
    }

    Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween) {
        Column {
            Text("Sat, 1 Jan", style = MaterialTheme.typography.caption)
            Text(formatDateTo12HourClock(time), style = MaterialTheme.typography.subtitle2)
        }

        Column {
            Text("SCREEN", style = MaterialTheme.typography.caption)
            Text("JET 01", style = MaterialTheme.typography.subtitle2)
        }

        Column {
            Text("SEATS", style = MaterialTheme.typography.caption)
            Text("J1, J2, J3", style = MaterialTheme.typography.subtitle2)
        }
    }
}

Now run the app. The content will not change with the time variable.

Then comment out the .capturable(captureController) part, and run again. You will see the value is updating correctly.

How to solve?

If I directly try this then everything works. So maybe DelegatingNode does not update the content for some reason.

@phucynwa
Copy link

phucynwa commented Feb 1, 2024

Same issue, my TextField's blink cursor does not work normally.

@PatilShreyas
Copy link
Owner

@ImaginativeShohag thanks for raising the issue. Will definitely check this issue

@PatilShreyas PatilShreyas added the bug Something isn't working label Feb 25, 2024
@PatilShreyas PatilShreyas changed the title capturable() content not updating Stateful UI content inside capturable() Modifier not updating on UI Feb 25, 2024
@PatilShreyas PatilShreyas linked a pull request Feb 25, 2024 that will close this issue
@PatilShreyas
Copy link
Owner

This has been fixed and released in v2.1.0 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants