collapseThen

fun SearchBarState.collapseThen(scope: CoroutineScope, action: () -> Unit)(source)

Collapses the bar at once and then runs action, so picking a result closes the overlay before the screen it opens, as Material's own search samples do. Runs inline unless an expand animation still holds the state, in which case action waits for it; if scope is canceled first, action never runs.