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

BackHandler doesn't propagate enabled changing #1672

Closed
veyndan opened this issue Nov 8, 2023 · 0 comments · Fixed by #1677
Closed

BackHandler doesn't propagate enabled changing #1672

veyndan opened this issue Nov 8, 2023 · 0 comments · Fixed by #1677
Assignees
Labels

Comments

@veyndan
Copy link
Contributor

veyndan commented Nov 8, 2023

For example, when running the following composable function:

@Composable
fun Foo() {
  var enabled by remember { mutableStateOf(true) }

  println("enabled = $enabled")
  BackHandler(enabled) { println("Back pressed") }

  LaunchedEffect(Unit) {
    delay(5.seconds)
    enabled = false
  }
}

We get the following output:

13:30:21   enabled = true
13:30:23   Back pressed
13:30:26   enabled = false
13:30:28   Back pressed

Having the initial value be false causes "Back pressed" to never be printed.

@veyndan veyndan added the bug label Nov 8, 2023
@veyndan veyndan self-assigned this Nov 8, 2023
@veyndan veyndan changed the title BackHandler doesn't propagate enabled changing in Redwood BackHandler doesn't propagate enabled changing Nov 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant