From 88feb841a979dd56287f8a5787052f12f25decb1 Mon Sep 17 00:00:00 2001 From: Felix Methe Date: Fri, 17 Feb 2023 13:56:58 +0100 Subject: [PATCH] fix: SearchField overlay actions are not performed See #348 for more details --- CHANGELOG.md | 3 ++ lib/src/fields/search_field.dart | 69 +++++++++++++++++--------------- pubspec.yaml | 2 +- 3 files changed, 40 insertions(+), 34 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 994154c1..757bc760 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## [1.10.1] +* Fixed an issue where the `MacosSearchField` would not perform an action when an item was selected. + ## [1.10.0] 🚨 Breaking Changes 🚨 * `MacosScrollbar` has been completely overhauled and now resembles the native macOS scrollbar in appearance and diff --git a/lib/src/fields/search_field.dart b/lib/src/fields/search_field.dart index d7eddb63..6c032f48 100644 --- a/lib/src/fields/search_field.dart +++ b/lib/src/fields/search_field.dart @@ -326,39 +326,42 @@ class _MacosSearchFieldState extends State> { } height += _kResultsOverlayMargin; - return MacosOverlayFilter( - borderRadius: _kBorderRadius, - color: MacosSearchFieldTheme.of(context).resultsBackgroundColor, - child: SizedBox( - height: height, - child: ListView.builder( - reverse: showOverlayAbove, - padding: const EdgeInsets.all(6.0), - itemCount: snapshot.data!.length, - itemBuilder: (context, index) { - var selectedItem = snapshot.data![index]!; - return _SearchResultItemButton( - resultHeight: widget.resultHeight, - onPressed: () { - searchController!.text = selectedItem.searchKey; - searchController!.selection = TextSelection.fromPosition( - TextPosition( - offset: searchController!.text.length, - ), - ); - selectedItem.onSelected?.call(); - // Hide the results - suggestionStream.sink.add(null); - if (widget.onResultSelected != null) { - widget.onResultSelected!(selectedItem); - } - }, - child: selectedItem.child ?? - Text( - selectedItem.searchKey, - ), - ); - }, + return TextFieldTapRegion( + child: MacosOverlayFilter( + borderRadius: _kBorderRadius, + color: MacosSearchFieldTheme.of(context).resultsBackgroundColor, + child: SizedBox( + height: height, + child: ListView.builder( + reverse: showOverlayAbove, + padding: const EdgeInsets.all(6.0), + itemCount: snapshot.data!.length, + itemBuilder: (context, index) { + var selectedItem = snapshot.data![index]!; + return _SearchResultItemButton( + resultHeight: widget.resultHeight, + onPressed: () { + searchController!.text = selectedItem.searchKey; + searchController!.selection = + TextSelection.fromPosition( + TextPosition( + offset: searchController!.text.length, + ), + ); + selectedItem.onSelected?.call(); + // Hide the results + suggestionStream.sink.add(null); + if (widget.onResultSelected != null) { + widget.onResultSelected!(selectedItem); + } + }, + child: selectedItem.child ?? + Text( + selectedItem.searchKey, + ), + ); + }, + ), ), ), ); diff --git a/pubspec.yaml b/pubspec.yaml index 7b6b263b..4c9876a3 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: macos_ui description: Flutter widgets and themes implementing the current macOS design language. -version: 1.10.0 +version: 1.10.1 homepage: "https://macosui.dev" repository: "https://github.com/GroovinChip/macos_ui"