Fix the unit dropdowns in the slot entry form discarding the selection

This commit is contained in:
Roland Geider
2026-07-30 21:50:41 +02:00
parent fe6d0a59df
commit 88f72a64bd
2 changed files with 15 additions and 9 deletions

View File

@@ -225,10 +225,7 @@ class _SlotEntryFormState extends ConsumerState<SlotEntryForm> {
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<SlotEntryForm> {
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,

View File

@@ -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),
),
),
);