ModalDrawer does not prevent tab navigation in background
See original GitHub issueSee this example code:
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material.DrawerValue
import androidx.compose.material.ModalDrawer
import androidx.compose.material.Text
import androidx.compose.material.TextButton
import androidx.compose.material.rememberDrawerState
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.DpSize
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.WindowState
import androidx.compose.ui.window.singleWindowApplication
fun main() = singleWindowApplication(WindowState(size = DpSize(300.dp,100.dp))) {
val drawerState = rememberDrawerState(DrawerValue.Open)
ModalDrawer(
drawerState = drawerState,
drawerContent = {
TextButton(onClick = {}) {
Text("Focusable as expected")
}
}
) {
Box(Modifier.fillMaxSize()) {
TextButton(onClick = {}, modifier = Modifier.align(Alignment.TopEnd)) {
Text("Should not be focusable")
}
}
}
}
Mouse interaction with the items in the background is prevented, but keyboard interaction (via Tab navigation and, e.g., Enter to click) is not:
I guess this might not be limited to Compose for Desktop, since focus management is not platform specific from what I could tell from the source code. In case it also affects Jetpack Compose, I’m not sure where to raise the issue.
Also, I didn’t find any way to conveniently disable all interaction (including tab navigation) of some composable including its children. Using Modifier.focusProperties { canFocus = false }
on the first child in content
did disable focus reception for some children, but not for all.
Issue Analytics
- State:
- Created 10 months ago
- Reactions:1
- Comments:9
Top Results From Across the Web
How can restrict the tab key press only within the modal popup ...
But when modal opened i want only the focus navigate within the modal popup. Working on Angular4, HTML5 project. Better if we find...
Read more >Navigation drawer – Material Design 3
Navigation drawers provide access to destinations in your app.
Read more >androidx.compose.material - Android Developers
Navigation drawer, ModalDrawer, Modal navigation drawer ... If persistentAppBar is set to false , then the backdrop will not show the app bar...
Read more >How to create a Navigation Drawer with Jetpack Compose
Creating the Navigation Drawer ... First, we going to create the menu items. We go to the project name folder and right-click, select...
Read more >Navigation Drawer using Jetpack Compose - ProAndroidDev
Jetpack Compose is the newest coolest Android toolkit from Google to ... To add a navigation drawer, we are using ModalDrawer composable ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Reported upstream: https://issuetracker.google.com/261572786
Also, add reproducer to GitHub: https://github.com/dima-avdeev-jb/desktop-background-focus