fix: back navigation on screens with no app bar actions

close #854
This commit is contained in:
edde746
2026-04-13 11:33:15 +02:00
parent 9208aa8d16
commit 17eb37cb37
@@ -47,13 +47,20 @@ mixin FocusableDetailScreenMixin<T extends StatefulWidget> on State<T>, GridFocu
setState(() {
isAppBarFocused = true;
});
actionBarKey.currentState?.getFocusNode(0).requestFocus();
final state = actionBarKey.currentState;
if (state != null && getAppBarActions().isNotEmpty) {
state.getFocusNode(0).requestFocus();
}
// Scroll to top to show the app bar
scrollController.animateTo(0, duration: const Duration(milliseconds: 200), curve: Curves.easeOut);
}
/// Handle BACK key from content - navigate to app bar and set flag to prevent PopScope exit
void handleBackFromContent() {
if (getAppBarActions().isEmpty) {
if (mounted) Navigator.pop(context);
return;
}
backHandledByKeyEvent = true;
navigateToAppBar();
}
@@ -83,8 +90,7 @@ mixin FocusableDetailScreenMixin<T extends StatefulWidget> on State<T>, GridFocu
return false;
}
if (isAppBarFocused) {
// Already on app bar, allow exit
if (isAppBarFocused || getAppBarActions().isEmpty) {
return true;
} else {
// Focus app bar first