What is the proper way to have a root BackHandler ...
# compose
What is the proper way to have a root BackHandler that have priority over the inner components (Typically a modalbottomsheet should intercept the backpress and not let an inner composable handle it before it's dismissed)
There are two ways to use BackHandler - unconditionally (which means that lower level handlers are triggered before the higher level handlers) or conditionally (i.e., only adding the BackHandler if your bottom sheet is showing, this ensuring that it is the last one registered)
It sounds like you want the later, which is indeed appropriate for 'overlay' style components
Of course, if you are using Accompanist Navigation Material and its support for bottom sheets, then you'll get the right back behavior by default, no work required
Arf thanks for the pointer I was looking at the wrong point. I'm using another library that uses enabled = sheetState.isVisible, instead of the if test, so it's added first and not last. I'll open a PR to fix that library. Thanks again for the eye opener about order of calls and not as the deepness of the compose hierarchy.