openMenu
Open a new submenu.
When the submenu is closed, the original menu is shown again.
Only the top-most menu is composed. While the submenu is open, the original menu (or the player controls, if no menu was open yet) leaves the composition, and any state remembered there with remember is disposed — state remembered with rememberSaveable (such as scroll positions) is restored when the submenu closes. So instead of passing state from the caller into menu, remember the state inside menu:
// Don't: audioTrackState is disposed while the menu is open
val audioTrackState = rememberAudioTrackState(player)
openMenu { AudioTrackMenu(audioTrackState) }
// Do
openMenu { AudioTrackMenu(rememberAudioTrackState(player)) }Content copied to clipboard