Repository navigation
Offer both kinds of search on every device - #1636
Conversation
Closing search clears the text but left the All / Books / Folders scope as it was. The list counts a scope other than All as filtering, so it kept showing every folder (or book) in the folder's subtree, with the scope bar hidden and nothing on screen saying the list was filtered. Reopening search didn't help either: the scope bar only shows once there's text. The only way out was to type something, pick All, and close again. The scope now goes back to All whenever search closes, which also matches a newly opened folder. The in-field clear button and hiding the keyboard keep search open, so they keep the scope.
iPhone had only the Search tab and iPad only the per-folder search, picked by device idiom. On iPhone Duo the idiom is the phone's on both displays, so the open phone got the iPhone set even at iPad size. Both are now on every device: the Search tab finds books across the library, and each folder has its own search with the All / Books / Folders scopes. Selecting the Search tab now activates its search, so its field shows up focused right away; on iPhone the tab opened with no field visible. Its prompt reads "Search Books" (it finds books only), from existing strings, so it doesn't read the same as the library root's "Search Library".
| } else { | ||
| /// Closing search clears the text but not the scope, and a scope other than All would keep | ||
| /// the list filtered with the scope bar hidden | ||
| scope = .all |
There was a problem hiding this comment.
🔵 INFO — No test covers the scope-reset invariant (closing search → scope == .all → isFiltering == false), and BookPlayerTests/ has no ItemListViewModel tests at all. This bug went unnoticed on iPad from #1544 until now. A small test would stop it coming back: set scope = .folders, set isSearchFocused = true, then false, and assert scope == .all and !isFiltering. Also test that turning on edit mode while searching resets the scope, since editMode now sets isSearchFocused = false and so resets the scope too.
✅ Claude PR Review —
|
Problem
ItemListViewModel.isFiltering). The list stayed on every folder (or book) in the folder's subtree, with the scope bar hidden and nothing on screen saying so. Reopening search didn't show why either: the scope bar only appears once there's text. This has been the case on iPad since Fix searching on iOS 18 #1544; iPhone gets it now that it has the folder search.Changes
MainView: the Search tab on every device.tabViewSearchActivation(.searchTabSelection)focuses its field when the tab is selected; on iPhone the tab used to open with no field visible.ItemListSearchableModifier: the per-folder search on every device, the root included.SearchView: the prompt reads "Search Books" (it finds books only), from existing strings, so it doesn't read the same as the library root's "Search Library".ItemListViewModel: the scope goes back to All whenever search closes. The in-field clear button and hiding the keyboard keep search open, so they keep the scope.Two commits: the scope fix (
fix(search)) applies on its own.Testing