Skip to content

Commit

Permalink
Fix MacosPulldownMenuItem.onTap doesn't open alert dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
TahaTesser committed Oct 3, 2024
1 parent 6313ee5 commit 40771dd
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 2 deletions.
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) {
menuEntity.onTap?.call();
Navigator.pop(context);
menuEntity.onTap?.call();
}
}

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
53 changes: 53 additions & 0 deletions test/buttons/pulldown_button_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -180,5 +180,58 @@ 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 FlutterLogo(size: 64),
title: const Text('Title'),
message: const Text('Message'),
primaryButton: PushButton(
controlSize: ControlSize.large,
onPressed: Navigator.of(context).pop,
child: const Text('Close'),
),
),
),
),
],
));
},
),
],
),
),
),
);

// Tap the first time
await tester.tap(find.text('test'));
await tester.pumpAndSettle();
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);
},
);
});
}

0 comments on commit 40771dd

Please sign in to comment.