Skip to content
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
25 changes: 15 additions & 10 deletions lib/features/main_screen/querya_window_title_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ class QueryaWindowTitleBar extends StatelessWidget {

@override
material.Widget build(material.BuildContext context) {
// The menu items' own contexts are deactivated once the menu closes, and
// a dialog opens a frame later: dialogs open from this one (#1777).
final titleBarContext = context;
final wb = context.workbench;
final environment = activeConnection?.environment;
final buttonColors = windowButtonColors(context);
Expand Down Expand Up @@ -222,7 +225,7 @@ class QueryaWindowTitleBar extends StatelessWidget {
trailing: Text(
Platform.isMacOS ? 'Cmd+P' : 'Ctrl+P',
).xSmall().muted(),
onPressed: (ctx) => showCommandPalette(ctx),
onPressed: (_) => showCommandPalette(titleBarContext),
child: const Text('Command Palette…'),
),
QueryaMenuItem(
Expand All @@ -233,12 +236,13 @@ class QueryaWindowTitleBar extends StatelessWidget {
trailing: Text(
Platform.isMacOS ? 'Cmd+K' : 'Ctrl+K',
).xSmall().muted(),
onPressed: (ctx) {
final host = QueryaCommandHost.maybeOf(ctx);
onPressed: (_) {
final host =
QueryaCommandHost.maybeOf(titleBarContext);
if (host?.onShowQuickSwitcher != null) {
host!.onShowQuickSwitcher!('');
} else {
showQuickSwitcher(ctx);
showQuickSwitcher(titleBarContext);
}
},
child: const Text('Go to Object…'),
Expand All @@ -248,7 +252,7 @@ class QueryaWindowTitleBar extends StatelessWidget {
material.Icons.tune_rounded,
size: 18,
),
onPressed: (ctx) => showPreferencesDialog(ctx),
onPressed: (_) => showPreferencesDialog(titleBarContext),
child: const Text('Preferences…'),
),
const QueryaMenuDivider(),
Expand All @@ -257,8 +261,8 @@ class QueryaWindowTitleBar extends StatelessWidget {
material.Icons.extension_rounded,
size: 18,
),
onPressed: (ctx) =>
showExtensionManagerDialog(ctx),
onPressed: (_) =>
showExtensionManagerDialog(titleBarContext),
child: const Text('Extensions…'),
),
],
Expand Down Expand Up @@ -332,7 +336,8 @@ class QueryaWindowTitleBar extends StatelessWidget {
leading: const material.Icon(
material.Icons.settings_rounded,
size: 18),
onPressed: (ctx) => showDriverManagerDialog(ctx),
onPressed: (_) =>
showDriverManagerDialog(titleBarContext),
child: const Text('Driver Manager'),
),
const QueryaMenuDivider(),
Expand Down Expand Up @@ -399,10 +404,10 @@ class QueryaWindowTitleBar extends StatelessWidget {
),
const QueryaMenuDivider(),
QueryaMenuItem(
onPressed: (ctx) => showAboutDialog(ctx),
onPressed: (_) => showAboutDialog(titleBarContext),
child: const Text('About')),
QueryaMenuItem(
onPressed: (ctx) => showUpdateDialog(ctx),
onPressed: (_) => showUpdateDialog(titleBarContext),
child: const Text('Check for Updates…'),
),
QueryaMenuItem(
Expand Down
24 changes: 24 additions & 0 deletions test/features/main_screen/querya_window_title_bar_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -206,4 +206,28 @@ void main() {

expect(toggled, isTrue);
});

testWidgets(
'Edit > Preferences… opens the dialog, although the menu has closed by '
'the time it opens (#1777)', (tester) async {
await tester.binding.setSurfaceSize(const Size(1400, 900));
addTearDown(() => tester.binding.setSurfaceSize(null));

await tester.pumpWidget(
queryaThemeTestShell(
child: QueryaWindowTitleBar(
onNewDatabaseConnection: () async {},
onNewDatabaseConnectionFromUrl: () async {},
),
),
);

await tester.tap(find.text('Edit'));
await tester.pumpAndSettle();
await tester.tap(find.text('Preferences…'));
await tester.pumpAndSettle();

expect(tester.takeException(), isNull);
expect(find.text('General'), findsWidgets);
});
}
Loading