Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Intervention or Survey not correctly saved when creating them first time #526

Closed
johannesvedder opened this issue Nov 14, 2023 · 2 comments · Fixed by #626
Closed

Comments

@johannesvedder
Copy link
Contributor

johannesvedder commented Nov 14, 2023

Bug seems to occur on all branches, including main (https://designer.studyu.health)

Steps to reproduce:

  • Create a new study
  • Give that study a name
  • Go to Intervention
  • Add a new intervention, modify the title and fill out the description
  • Add a intervention task, fill out title
  • Save both
  • Click on "Unnamed intervention". Neither the intervention title nor the intervention description are saved. Only the task is saved correctly.

The same happens with a new measurement survey. After the bug occured once, it does not happen anymore.

Solution

Seems to be related to https://github.com/hpi-studyu/studyu/blob/dev/designer_v2/lib/features/study/study_test_controller.dart

Removing all occurences of studyTestControllerProvider solves the issue (here and here)

@hig-dev
Copy link
Contributor

hig-dev commented Nov 15, 2023

Here are the minimal steps to reproduce.

Steps to reproduce:

  • Create a new study
  • Give that study a name
  • Go to Intervention
  • Add a new intervention, modify the title
  • Save
  • Click on "Unnamed intervention". The intervention title is not saved.

I found the root cause for this bug. It has something to do with the instances of InterventionFormViewModel. Multiple instances of InterventionFormViewModel are created and the ReactiveTextField updates instance A, but the save function saves the data from instance B which was not updated. I am investigating this further to find a fix for this bug.

Edit 1:

The two instances of InterventionFormViewModel are created because of:

@override
Widget build(BuildContext context, WidgetRef ref) {
final state = ref.watch(studyControllerProvider(studyId));
// TODO: this architecture results in a 2-stage loading (app init/splash, study)
// TODO: figure out a way to declare + load data dependencies for routes in one go
return AsyncValueWidget(
value: state.study,
data: (study) {
final formViewModel = formViewModelBuilder(ref);
return FormScaffold(
formViewModel: formViewModel,
body: formViewBuilder(formViewModel),
);
//return formViewBuilder(formViewModel);
},
);
}
)

@hig-dev
Copy link
Contributor

hig-dev commented Dec 16, 2023

I think this issue is related to joanpablo/reactive_forms#262

@johannesvedder johannesvedder linked a pull request Jun 17, 2024 that will close this issue
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants