Merge pull request #1429 from srothgan/fix/1428-gym-mode-keyboard

Dismiss the number pad after saving a set in Gym Mode
This commit is contained in:
Roland Geider
2026-11-26 16:58:23 +01:00
committed by GitHub
2 changed files with 39 additions and 0 deletions

View File

@@ -398,11 +398,14 @@ class _LogFormWidgetState extends ConsumerState<LogFormWidget> {
// error handler; the success path below is then skipped. A page
// logged before updates its row, and the PageView follows the
// page change from the gym state.
final inputFocus = FocusManager.instance.primaryFocus;
await ref.read(gymStateProvider.notifier).logCurrentSet();
if (!context.mounted) {
return;
}
inputFocus?.unfocus();
showSnackbar(
context,
i18n.successfullySaved,

View File

@@ -282,6 +282,42 @@ void main() {
expect(captured[1], gymState.dayId);
});
for (final fieldKey in ['logs-reps-widget', 'logs-weight-widget']) {
testWidgets('save dismisses the keyboard after a successful write from $fieldKey', (
tester,
) async {
final write = Completer<void>();
when(
mockWorkoutLogRepo.addLocalDrift(any, dayId: anyNamed('dayId')),
).thenAnswer((_) => write.future);
seedLogPage(testdata.getTestRoutine());
await pumpLogPage(tester);
final field = find.descendant(
of: find.byKey(ValueKey(fieldKey)),
matching: find.byType(TextFormField),
);
await tester.enterText(field, '12');
await tester.pump();
final input = tester.widget<EditableText>(
find.descendant(of: field, matching: find.byType(EditableText)),
);
expect(input.focusNode.hasFocus, isTrue);
expect(tester.testTextInput.isVisible, isTrue);
await tester.tap(find.byKey(const ValueKey('save-log-button')));
await tester.pump();
expect(input.focusNode.hasFocus, isTrue);
expect(tester.testTextInput.isVisible, isTrue);
write.complete();
await tester.pumpAndSettle();
expect(input.focusNode.hasFocus, isFalse);
expect(tester.testTextInput.isVisible, isFalse);
});
}
testWidgets('carries the logged values over to the next set when sticky values are enabled', (
tester,
) async {