A cross platform Audiobookshelf client for Android and iOS
Dart
Fix grid-tile taps and search keyboard dropping
Barnabasccfcffbedd21
diff --git a/lib/screens/library_screen.dart b/lib/screens/library_screen.dartindex 9543606a..19230b9e 100644--- a/lib/screens/library_screen.dart+++ b/lib/screens/library_screen.dart@@ -66,6 +66,11 @@ class LibraryScreenState extends State<LibraryScreen> with TickerProviderStateMi// ── Search state ──final _searchController = TextEditingController();final _focusNode = FocusNode();+ /// GlobalKey on the SearchBar so its Element (and the TextField + focus+ /// inside) survives the tree swap when `_isInSearchMode` flips. Without+ /// this, typing the first character unmounts the tabbed tree, the+ /// SearchBar element is destroyed, and the keyboard drops.+ final _searchBarKey = GlobalKey();Timer? _debounce;/// Whether the search bar has active text.@@ -1696,6 +1701,12 @@ class LibraryScreenState extends State<LibraryScreen> with TickerProviderStateMiPadding(padding: const EdgeInsets.fromLTRB(16, 8, 16, 0),child: SearchBar(+ // Same GlobalKey on whichever SearchBar gets the shared+ // focus, so when _isInSearchMode toggles and the tree+ // swaps from tabbed -> search results, Flutter re-parents+ // the existing Element instead of destroying and+ // recreating it. Keeps focus + keyboard alive.+ key: useSharedFocus ? _searchBarKey : null,controller: _searchController,// Only the active tab's SearchBar binds to the screen-// level focus node. Inactive tabs' SearchBars use theirdiff --git a/lib/widgets/library_grid_tiles.dart b/lib/widgets/library_grid_tiles.dartindex 30d44ca6..ccea1ddb 100644--- a/lib/widgets/library_grid_tiles.dart+++ b/lib/widgets/library_grid_tiles.dart@@ -68,6 +68,11 @@ class _GridBookTileState extends State<GridBookTile> {lib.isPodcastLibrary ? lib.getUnfinishedEpisodeCount(widget.item) : 0;return GestureDetector(+ // opaque so taps on the blank space below the title (the tile's tall+ // aspect ratio leaves a gap when the Column children stop short)+ // still trigger the onTap. Without this, taps in that blank strip+ // miss the Column's hit test and nothing happens.+ behavior: HitTestBehavior.opaque,onTap: () {if (itemId.isNotEmpty) {if (lib.isPodcastLibrary) {@@ -516,6 +521,7 @@ class GridSeriesTile extends StatelessWidget {final seriesProgress = itemIds.isNotEmpty ? totalProgress / itemIds.length : 0.0;return GestureDetector(+ behavior: HitTestBehavior.opaque,onTap: () {if (seriesId.isNotEmpty) {showSeriesBooksSheet(@@ -626,18 +632,20 @@ class GridSeriesTileDirect extends StatelessWidget {final seriesProgress = books.isNotEmpty ? totalProgress / books.length : 0.0;return GestureDetector(+ behavior: HitTestBehavior.opaque,onTap: () {- if (seriesId.isNotEmpty) {- showSeriesBooksSheet(- context,- seriesName: seriesName,- seriesId: seriesId,- books: const [],- serverUrl: auth.serverUrl,- token: auth.token,- parentSeriesId: parentSeriesId,- );- }+ // When seriesId is missing (e.g. collapsed-series tiles inferred from+ // book metadata in the author sheet), open the sheet with the books+ // we already have rather than dropping the tap silently.+ showSeriesBooksSheet(+ context,+ seriesName: seriesName,+ seriesId: seriesId.isEmpty ? null : seriesId,+ books: seriesId.isEmpty ? books : const [],+ serverUrl: auth.serverUrl,+ token: auth.token,+ parentSeriesId: parentSeriesId,+ );},child: Column(crossAxisAlignment: CrossAxisAlignment.start,@@ -706,6 +714,7 @@ class GridAuthorTile extends StatelessWidget {final headers = lib.mediaHeaders;return GestureDetector(+ behavior: HitTestBehavior.opaque,onTap: () {if (authorId.isNotEmpty) {showAuthorDetailSheet(context, authorId: authorId, authorName: name);