From 88f72a64bd7c32fa11036b2f06a45a6385c3fbd8 Mon Sep 17 00:00:00 2001 From: Roland Geider Date: Thu, 30 Jul 2026 21:50:41 +0200 Subject: [PATCH] Fix the unit dropdowns in the slot entry form discarding the selection --- .../routines/widgets/forms/slot_entry.dart | 10 ++-------- .../widgets/forms/slot_entry_form_test.dart | 14 +++++++++++++- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/lib/features/routines/widgets/forms/slot_entry.dart b/lib/features/routines/widgets/forms/slot_entry.dart index e03269f0c..dceebe940 100644 --- a/lib/features/routines/widgets/forms/slot_entry.dart +++ b/lib/features/routines/widgets/forms/slot_entry.dart @@ -225,10 +225,7 @@ class _SlotEntryFormState extends ConsumerState { if (!widget.simpleMode) WeightUnitInputWidget( widget.entry.weightUnitObj, - onChanged: (value) { - widget.entry.weightUnitObj = null; - widget.entry.weightUnitId = null; - }, + onChanged: (value) => widget.entry.weightUnit = value, ), Row( spacing: 10, @@ -259,10 +256,7 @@ class _SlotEntryFormState extends ConsumerState { if (!widget.simpleMode) RepetitionUnitInputWidget( widget.entry.repetitionUnitObj, - onChanged: (value) { - widget.entry.repetitionUnitObj = null; - widget.entry.repetitionUnitId = null; - }, + onChanged: (value) => widget.entry.repetitionUnit = value, ), Row( spacing: 10, diff --git a/test/features/routines/widgets/forms/slot_entry_form_test.dart b/test/features/routines/widgets/forms/slot_entry_form_test.dart index 47307d1d5..a9d1dd2ac 100644 --- a/test/features/routines/widgets/forms/slot_entry_form_test.dart +++ b/test/features/routines/widgets/forms/slot_entry_form_test.dart @@ -129,6 +129,16 @@ void main() { await tester.tap(find.byKey(const ValueKey('slot-entry-type-option-myo')), warnIfMissed: false); await tester.pumpAndSettle(); + // Set the units (select by name, the item keys collide between the dropdowns) + await tester.tap(find.byType(WeightUnitInputWidget)); + await tester.pumpAndSettle(); + await tester.tap(find.text(testWeightUnit2.name).last, warnIfMissed: false); + await tester.pumpAndSettle(); + await tester.tap(find.byType(RepetitionUnitInputWidget)); + await tester.pumpAndSettle(); + await tester.tap(find.text(testRepetitionUnit2.name).last, warnIfMissed: false); + await tester.pumpAndSettle(); + await tester.tap(find.byKey(const ValueKey(SUBMIT_BUTTON_KEY_NAME))); await tester.pumpAndSettle(); @@ -139,7 +149,9 @@ void main() { .having((d) => d.id, 'id', null) .having((d) => d.slotId, 'slotId', 1) .having((d) => d.order, 'order', 1) - .having((d) => d.type, 'type', SlotEntryType.myo), + .having((d) => d.type, 'type', SlotEntryType.myo) + .having((d) => d.weightUnitId, 'weightUnitId', testWeightUnit2.id) + .having((d) => d.repetitionUnitId, 'repetitionUnitId', testRepetitionUnit2.id), ), ), );