You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description: Views that are detached from the window shouldn’t respond to predictive back gestures. Take a tabbed view, for example, with open search bar results on the second tab. When on the first tab the search bar should no longer receive the back callback because it prevents the user from closing the app (see video below).
Screen.Recording.2024-05-13.at.17.47.50.mov
Expected behavior: The gesture back on the first tab should close the app instead of being received by the search bar. In the video below you can see the gesture back correctly closes the app when the search bar results aren’t open.
Screen.Recording.2024-05-13.at.17.47.00.mov
Source code: The screenshot shows the search bar receives the back callback even though it isn't attached to the window.
Minimal sample app repro: The 2 videos above were taken from the minimal sample repo. I built it from the “Bottom Navigation Views Activity” template in Android Studio and added a search bar to the dashboard tab. The steps to recreate the bug are in the README.
Android API version: 34
Material Library version: 1.12.0
Device: Pixel 6 Pro simulator
The text was updated successfully, but these errors were encountered:
grahammendick
changed the title
[Search bar][Bottom sheet] Should stop listening for back callbacks when detached from window
[Search bar] Should stop listening for back callbacks when detached from window
May 14, 2024
All navigation stacks have the same fragment manager. A fragment manager can only have one primary navigation stack because that's the one that receives the gesture back. So dynamically set the primary stack when the stack is attached to the window.
The recommended way to handle nested stacks is for them to [share a fragment manager](https://developer.android.com/guide/fragments/fragmentmanager#multiple-back-stacks). Then save and restore the back stack when tabs change. But no need for that for now.
Should one day support different fragment managers on ancestor stacks so that could possibly have the child handle gesture back and then the ancestor when child stack is gone. Could probably also do this without different fragment managers by updating primary to the ancestor when child goes.
Also found a [material component bug](material-components/material-components-android#4176) while investigating nested stacks.
@dsn5ft Thanks for working on this!
Don't you have to start listening for back callbacks again when the SearchView is attached to window? That's equivalent to tabbing back to the dashboard tab and then gesture back
…in onAttachedToWindow() and remove modal for accessibility state in onDetachedFromWindow()
Fixes an issue where nothing is focusable in TalkBack after removing SearchView, due to the modal for accessibility behavior
Resolves#4176
PiperOrigin-RevId: 644038017
Description: Views that are detached from the window shouldn’t respond to predictive back gestures. Take a tabbed view, for example, with open search bar results on the second tab. When on the first tab the search bar should no longer receive the back callback because it prevents the user from closing the app (see video below).
Screen.Recording.2024-05-13.at.17.47.50.mov
Expected behavior: The gesture back on the first tab should close the app instead of being received by the search bar. In the video below you can see the gesture back correctly closes the app when the search bar results aren’t open.
Screen.Recording.2024-05-13.at.17.47.00.mov
Source code: The screenshot shows the search bar receives the back callback even though it isn't attached to the window.
Minimal sample app repro: The 2 videos above were taken from the minimal sample repo. I built it from the “Bottom Navigation Views Activity” template in Android Studio and added a search bar to the dashboard tab. The steps to recreate the bug are in the README.
Android API version: 34
Material Library version: 1.12.0
Device: Pixel 6 Pro simulator
The text was updated successfully, but these errors were encountered: