Hover over item 50 and remove your hand from the mousepad.
Move focus upwards using directional keys until scrolling occurs.
Expected results
The hovered menu item should not regain focus on scroll. Traversal should continue from the item that was focused before scrolling.
Actual results
The hovered menu item regains focus on scroll.
Code sample
Code sample
```dart
import 'package:flutter/material.dart';
void main() => runApp(const Bug());
// Reproduce: hover cursor on item 3. Press down arrow key until you reach the
// bottom of the menu. Move cursor off item 3 then back on item 3. Press up
// arrow key.
class Bug extends StatelessWidget {
const Bug({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
theme:
ThemeData(colorSchemeSeed: Colors.blue, brightness: Brightness.dark),
home: const BugApp(),
);
}
}
class BugApp extends StatefulWidget {
const BugApp({
super.key,
});
@override
State createState() => _BugAppState();
}
class _BugAppState extends State {
FocusNode focusNode = FocusNode();
@override
Widget build(BuildContext context) {
return Material(
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
MenuAnchor(
childFocusNode: focusNode,
builder: (context, controller, child) {
return TextButton(
focusNode: focusNode,
onPressed: () {
if (controller.isOpen) {
controller.close();
} else {
controller.open();
}
},
child: Text('Open'),
);
},
menuChildren: [
for(var i = 0; i < 100; i++)
MenuItemButton(
child: Text('Item $i'),
onPressed: () {},
),
],
),
],
),
),
);
}
}
```
Screenshots or Video
Screenshots / Video demonstration
https://github.com/flutter/flutter/assets/59215665/67a7d9f3-2bde-4485-8cfc-5f881550bf13
Logs
Logs
```console
No applicable logs
```
Flutter Doctor output
Doctor output
```console
[✓] Flutter (Channel master, 3.23.0-13.0.pre.350, on macOS 14.0 23A344 darwin-arm64, locale en-US)
• Flutter version 3.23.0-13.0.pre.350 on channel master at /Users/davidhicks/fvm/versions/master
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision a52e266b79 (9 hours ago), 2024-06-26 14:59:56 -0700
• Engine revision 1d5e3cc55a
• Dart version 3.5.0 (build 3.5.0-299.0.dev)
• DevTools version 2.36.0
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /Users/davidhicks/Library/Android/sdk
• Platform android-34, build-tools 34.0.0
• ANDROID_HOME = /Users/davidhicks/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11609105)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 15F31d
• CocoaPods version 1.15.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2024.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11609105)
[✓] VS Code (version 1.90.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.90.0
[✓] Connected device (3 available)
• macOS (desktop) • macos • darwin-arm64 • macOS 14.0 23A344 darwin-arm64
• Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin • macOS 14.0 23A344 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 126.0.6478.127
! Error: Browsing on the local area network for David’s iPhone. Ensure the device is unlocked and attached with a cable or associated with the same local area network as
this Mac.
The device must be opted into Developer Mode to connect wirelessly. (code -27)
[✓] Network resources
• All expected network resources are available.
• No issues found!
```
Reproducible using the code sample and the steps outlined above.
flutter doctor -v
```
[!] Flutter (Channel stable, 3.22.2, on macOS 14.4.1 23E224 darwin-arm64, locale en-GB)
• Flutter version 3.22.2 on channel stable at /Users/nexus/dev/sdks/flutter
! Warning: `flutter` on your path resolves to /Users/nexus/dev/sdks/flutters/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/nexus/dev/sdks/flutter. Consider adding /Users/nexus/dev/sdks/flutter/bin to the front of your path.
! Warning: `dart` on your path resolves to /Users/nexus/dev/sdks/flutters/bin/dart, which is not inside your current Flutter SDK checkout at /Users/nexus/dev/sdks/flutter. Consider adding /Users/nexus/dev/sdks/flutter/bin to the front of your path.
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 761747bfc5 (3 weeks ago), 2024-06-05 22:15:13 +0200
• Engine revision edd8546116
• Dart version 3.4.3
• DevTools version 2.34.3
• If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /Users/nexus/Library/Android/sdk
• Platform android-34, build-tools 34.0.0
• Java binary at: /Users/nexus/Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11609105)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 15.3)
• Xcode at /Applications/Xcode-15.3.0.app/Contents/Developer
• Build 15E204a
• CocoaPods version 1.15.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2024.1)
• Android Studio at /Users/nexus/Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11609105)
[✓] IntelliJ IDEA Ultimate Edition (version 2023.2.5)
• IntelliJ at /Users/nexus/Applications/IntelliJ IDEA Ultimate.app
• Flutter plugin version 77.2.2
• Dart plugin version 232.10286
[✓] VS Code (version 1.90.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.90.0
[✓] Connected device (5 available)
• Nexus (mobile) • 00008020-001875E83A38002E • ios • iOS 17.5.1 21F90
• Dean’s iPad (mobile) • 00008103-000825C811E3401E • ios • iOS 17.5.1 21F90
• macOS (desktop) • macos • darwin-arm64 • macOS 14.4.1 23E224 darwin-arm64
• Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin • macOS 14.4.1 23E224 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 126.0.6478.127
[✓] Network resources
• All expected network resources are available.
! Doctor found issues in 1 category.
```
```
[✓] Flutter (Channel master, 3.23.0-13.0.pre.357, on macOS 14.4.1 23E224 darwin-arm64, locale en-GB)
• Flutter version 3.23.0-13.0.pre.357 on channel master at /Users/nexus/dev/sdks/flutters
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 805d79607e (5 hours ago), 2024-06-27 05:53:58 +0200
• Engine revision a9194f0f01
• Dart version 3.5.0 (build 3.5.0-304.0.dev)
• DevTools version 2.36.0
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /Users/nexus/Library/Android/sdk
• Platform android-34, build-tools 34.0.0
• Java binary at: /Users/nexus/Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11609105)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 15.3)
• Xcode at /Applications/Xcode-15.3.0.app/Contents/Developer
• Build 15E204a
• CocoaPods version 1.15.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2024.1)
• Android Studio at /Users/nexus/Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11609105)
[✓] IntelliJ IDEA Ultimate Edition (version 2023.2.5)
• IntelliJ at /Users/nexus/Applications/IntelliJ IDEA Ultimate.app
• Flutter plugin version 77.2.2
• Dart plugin version 232.10286
[✓] VS Code (version 1.90.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.90.0
[✓] Connected device (5 available)
• Nexus (mobile) • 00008020-001875E83A38002E • ios • iOS 17.5.1 21F90
• Dean’s iPad (mobile) • 00008103-000825C811E3401E • ios • iOS 17.5.1 21F90
• macOS (desktop) • macos • darwin-arm64 • macOS 14.4.1 23E224 darwin-arm64
• Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin • macOS 14.4.1 23E224 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 126.0.6478.127
[✓] Network resources
• All expected network resources are available.
• No issues found!
```
Steps to reproduce
Expected results
The hovered menu item should not regain focus on scroll. Traversal should continue from the item that was focused before scrolling.
Actual results
The hovered menu item regains focus on scroll.
Code sample
Code sample
```dart import 'package:flutter/material.dart'; void main() => runApp(const Bug()); // Reproduce: hover cursor on item 3. Press down arrow key until you reach the // bottom of the menu. Move cursor off item 3 then back on item 3. Press up // arrow key. class Bug extends StatelessWidget { const Bug({super.key}); @override Widget build(BuildContext context) { return MaterialApp( theme: ThemeData(colorSchemeSeed: Colors.blue, brightness: Brightness.dark), home: const BugApp(), ); } } class BugApp extends StatefulWidget { const BugApp({ super.key, }); @override StateScreenshots or Video
Screenshots / Video demonstration
https://github.com/flutter/flutter/assets/59215665/67a7d9f3-2bde-4485-8cfc-5f881550bf13Logs
Logs
```console No applicable logs ```Flutter Doctor output
Doctor output
```console [✓] Flutter (Channel master, 3.23.0-13.0.pre.350, on macOS 14.0 23A344 darwin-arm64, locale en-US) • Flutter version 3.23.0-13.0.pre.350 on channel master at /Users/davidhicks/fvm/versions/master • Upstream repository https://github.com/flutter/flutter.git • Framework revision a52e266b79 (9 hours ago), 2024-06-26 14:59:56 -0700 • Engine revision 1d5e3cc55a • Dart version 3.5.0 (build 3.5.0-299.0.dev) • DevTools version 2.36.0 [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) • Android SDK at /Users/davidhicks/Library/Android/sdk • Platform android-34, build-tools 34.0.0 • ANDROID_HOME = /Users/davidhicks/Library/Android/sdk • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11609105) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 15.4) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 15F31d • CocoaPods version 1.15.2 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2024.1) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11609105) [✓] VS Code (version 1.90.2) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.90.0 [✓] Connected device (3 available) • macOS (desktop) • macos • darwin-arm64 • macOS 14.0 23A344 darwin-arm64 • Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin • macOS 14.0 23A344 darwin-arm64 • Chrome (web) • chrome • web-javascript • Google Chrome 126.0.6478.127 ! Error: Browsing on the local area network for David’s iPhone. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac. The device must be opted into Developer Mode to connect wirelessly. (code -27) [✓] Network resources • All expected network resources are available. • No issues found! ```