Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ import androidx.compose.foundation.lazy.LazyRow
import androidx.compose.foundation.lazy.items
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
Expand Down Expand Up @@ -81,15 +85,20 @@ fun RoomSelectView(
)
}

var canHandleBack by remember { mutableStateOf(true) }
fun onBackButton(state: RoomSelectState) {
if (state.isSearchActive) {
state.eventSink(RoomSelectEvents.ToggleSearchActive)
} else {
canHandleBack = false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is OK, but we do not check the value of canHandleBack before setting it and invoking onDismiss? Asking because navigationIcon click also invokes the fun onBackButton.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, calling onBackButton from the back navigation icon could cause a different issue (2 or more back paginations if called quickly?), but it wouldn't interfere with the BackHandler here AFAICT.

onDismiss()
}
}

BackHandler(onBack = { onBackButton(state) })
BackHandler(
enabled = canHandleBack,
onBack = { onBackButton(state) }
)

Scaffold(
modifier = modifier,
Expand Down
Loading