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.
This commit is contained in:
2026-11-10 21:33:07 +00:00
parent fdc730422d
commit 16afda3634
11 changed files with 223 additions and 28 deletions
@@ -1,3 +1,4 @@
import '../../../ui/adaptive/app_menu_anchor.dart';
import 'dart:async';
import 'package:flutter/cupertino.dart';
@@ -158,9 +159,7 @@ class _ChatEffortControlState extends State<ChatEffortControl> {
),
);
}
return MenuAnchor(
// Above every floating window, and not clipped to one.
useRootOverlay: true,
return AppMenuAnchor(
menuChildren: [
Padding(
padding: const EdgeInsets.fromLTRB(12, 8, 12, 4),
@@ -301,7 +301,18 @@ class _ChatThreadViewState extends State<ChatThreadView> {
_filesSheetOpen = true;
final cupertino =
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
final sheet = cupertino
// In a floating window the explorer is a page of that window, so a file
// it opens stays in the window too.
final sheet = WindowScope.maybeOf(context) != null
? Navigator.of(context).push<void>(
MaterialPageRoute<void>(
builder: (_) => Scaffold(
appBar: AppBar(title: const Text('Files')),
body: FilesPanel(controller: _files),
),
),
)
: cupertino
? showCupertinoModalPopup<void>(
context: context,
builder: (_) => Align(
@@ -1,3 +1,4 @@
import '../../../ui/adaptive/app_menu_anchor.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
@@ -108,9 +109,7 @@ class PipelineSortButton extends StatelessWidget {
),
);
}
return MenuAnchor(
// Above every floating window, and not clipped to one.
useRootOverlay: true,
return AppMenuAnchor(
menuChildren: [
for (final option in PipelineSort.values)
MenuItemButton(