Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix MacosPulldownMenuItem.onTap doesn't open alert dialog #520

Merged
merged 2 commits into from
Oct 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## [2.1.1]
* Fixed a bug where `MacosPulldownMenuItem` would not show an alert dialog when tapped.

## [2.1.0]
* Updated dependencies
* Support macOS 15
Expand Down
2 changes: 1 addition & 1 deletion lib/src/buttons/pulldown_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ class _MacosPulldownMenuItemButtonState
final MacosPulldownMenuEntry menuEntity =
widget.route.items[widget.itemIndex].item!;
if (menuEntity is MacosPulldownMenuItem) {
Navigator.of(context).pop();
menuEntity.onTap?.call();
Navigator.pop(context);
}
}

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: 2.1.0
version: 2.1.1
homepage: "https://macosui.dev"
repository: "https://github.com/GroovinChip/macos_ui"

Expand Down
54 changes: 54 additions & 0 deletions test/buttons/pulldown_button_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -180,5 +180,59 @@ void main() {
],
);
});

testWidgets(
'MacosPulldownMenuItem.onTap shows alert dialog',
(WidgetTester tester) async {
await tester.pumpWidget(
MacosApp(
home: MacosWindow(
child: MacosScaffold(
children: [
ContentArea(
builder: (context, _) {
return Center(
child: MacosPulldownButton(
title: "test",
items: [
MacosPulldownMenuItem(
title: const Text('Open Alert Dialog'),
onTap: () => showMacosAlertDialog(
context: context,
builder: (context) => MacosAlertDialog(
appIcon: const MacosIcon(CupertinoIcons.eyedropper),
title: const Text('Title'),
message: const Text('Message'),
primaryButton: PushButton(
controlSize: ControlSize.large,
onPressed: Navigator.of(context).pop,
child: const Text('Close'),
),
),
),
),
],
));
},
),
],
),
),
),
);

// Tap the pulldown button.
await tester.tap(find.text('test'));
await tester.pumpAndSettle();
// Tap the menu item to show the alert dialog.
await tester.tap(find.text('Open Alert Dialog'));
await tester.pumpAndSettle();

expect(find.text('Open Alert Dialog'), findsNothing);
expect(find.text('Title'), findsOneWidget);
expect(find.text('Message'), findsOneWidget);
expect(find.text('Close'), findsOneWidget);
},
);
});
}
Loading