Skip to content

[Search bar] Should stop listening for back callbacks when detached from window #4176

@grahammendick

Description

@grahammendick

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.

Screenshot 2024-05-13 at 17 53 22

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions