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
3 changes: 3 additions & 0 deletions lib/features/main_screen/main_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ class _MainScreenState extends State<MainScreen> {

bool _handleGlobalKeyEvent(KeyEvent event) {
if (event is! KeyDownEvent) return false;
// A dialog or sheet is on top: the screen's shortcuts must not reach
// through it (Ctrl+N over the welcome tour opened a second dialog, #1820).
if (ModalRoute.of(context)?.isCurrent == false) return false;

final keyboard = HardwareKeyboard.instance;
final shortcut = MainScreenShortcuts.resolve(
Expand Down
55 changes: 52 additions & 3 deletions test/features/main_screen/sidebar_toggle_test.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import 'package:flutter/widgets.dart';
import 'dart:async';
import 'dart:io';

import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';

import 'package:flutter/material.dart' as material;
import 'package:flutter_test/flutter_test.dart';
import 'package:path_provider_platform_interface/path_provider_platform_interface.dart';
Expand Down Expand Up @@ -47,8 +50,7 @@ void main() {
});

group('Fluid Collapsible Sidebar (#557)', () {
test('AppSettings preserves sidebarVisible across sets and gets',
() async {
test('AppSettings preserves sidebarVisible across sets and gets', () async {
expect(await AppSettings.instance.getSidebarVisible(), isTrue);

await AppSettings.instance.setSidebarVisible(false);
Expand Down Expand Up @@ -252,6 +254,53 @@ void main() {
);
});

testWidgets('Ctrl+B does not reach through an open dialog (#1820)',
(tester) async {
await tester.pumpWidget(
queryaThemeTestShell(
child: const material.SizedBox(
width: 1200,
height: 800,
child: MainScreen(),
),
),
);
await tester.pumpAndSettle();

bool sidebarHidden() => find
.ancestor(
of: find.byType(ConnectionsPanel, skipOffstage: false),
matching: find.byWidgetPredicate(
(w) => w is material.Offstage && w.offstage,
skipOffstage: false,
),
)
.evaluate()
.isNotEmpty;

final context = tester.element(find.byType(MainScreen));
unawaited(material.showDialog<void>(
context: context,
builder: (_) => const material.AlertDialog(content: Text('modal')),
));
await tester.pumpAndSettle();

await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft);
await tester.sendKeyEvent(LogicalKeyboardKey.keyB);
await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft);
await tester.pumpAndSettle();
expect(sidebarHidden(), isFalse);

material.Navigator.of(context).pop();
await tester.pumpAndSettle();

await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft);
await tester.sendKeyEvent(LogicalKeyboardKey.keyB);
await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft);
await tester.pumpAndSettle();
expect(sidebarHidden(), isTrue);
});

testWidgets(
'isolates workspace layout constraints during sidebar spring animation (#984)',
(tester) async {
Expand Down
Loading