Skip to content

Commit

Permalink
fix: SearchField overlay actions are not performed
Browse files Browse the repository at this point in the history
See macosui#348 for more details
  • Loading branch information
FelixMethe committed Feb 17, 2023
1 parent 10dda17 commit 88feb84
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 34 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
69 changes: 36 additions & 33 deletions lib/src/fields/search_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -326,39 +326,42 @@ class _MacosSearchFieldState<T> extends State<MacosSearchField<T>> {
}
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,
),
);
},
),
),
),
);
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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"

Expand Down

0 comments on commit 88feb84

Please sign in to comment.