how to make accessibility focus stay inside current fragment

1.4k Views Asked by At

How can I make focus navigation to stay inside the current fragment? Or, how can I set focusable to false for a whole fragment or view with its all child view?

full explanation:

I'm making my Android app accessible.

I have this situation:

home fragment (A) is being covered by login fragment (B) after clicking on the title "log in". as you can see here:

fragments diagram

after click on "log in", login fragment gets focus, and until clicking on back I want the accessibility focus to stay inside the login fragment (when the user navigate through focus navigation) rather then keep jumping between covered elements in fragment A.

How can I make focus navigation to stay inside fragment B? Or, instead:

How can I set focusable to false for the all of the child views in fragment A?

thanks!

1

There are 1 best solutions below

2
On BEST ANSWER

You need an accessible modal dialog. It's a pretty common thing. Greg Kraus, the former accessibility guru at NCSU wrote a great blog on this topic - https://github.com/gdkraus/accessible-modal-dialog

You essentially need to create a big <div> to cover your main window and make the z-order on top of your main window. This big <div> could have opacity set on it if want the main window to appear disabled. The <div> doesn't accept any input so the user can't move the focus back to the main window. Then your login dialog would have a z-order higher than the <div>.