Files
pipelines/app/test/shell/windows/window_popup_rules_test.dart
alan 16afda3634 Close menus with Escape and keep a window's popups focused
AppMenuAnchor is the app's one MenuAnchor: root overlay, takes the keyboard
while open (Escape and arrows work wherever focus was) and gives it back.
A window no longer takes the keyboard back from a popup its own press
opened. In a window, Files opens as a page of that window and Chat details
is in the More menu.
2026-11-10 21:33:07 +00:00

25 lines
1.0 KiB
Dart

import 'dart:io';
import 'package:flutter_test/flutter_test.dart';
/// Window content takes input only inside its window (see `WindowNavigator`),
/// so a menu panel, which may extend past the window, must be in the root
/// overlay. Any content can end up in a window, so the app's menus are all
/// `AppMenuAnchor`, the one place a `MenuAnchor` is built.
void main() {
test('MenuAnchor is used only through AppMenuAnchor', () {
final offenders = <String>[];
for (final file in Directory('lib').listSync(recursive: true)) {
if (file is! File || !file.path.endsWith('.dart')) continue;
if (file.path.endsWith('ui/adaptive/app_menu_anchor.dart')) continue;
final source = file.readAsStringSync();
for (final match in RegExp(r'\bMenuAnchor\(').allMatches(source)) {
if (match.start > 0 && source[match.start - 1] == 'p') continue;
final line = '\n'.allMatches(source.substring(0, match.start)).length;
offenders.add('${file.path}:${line + 1}');
}
}
expect(offenders, isEmpty);
});
}