fix: Linked table nested form lifecycle - preserve parent form state across child form sessions#591
Open
najuna-brian wants to merge 1 commit intoOpenDataEnsemble:devfrom
Open
Conversation
…across child form sessions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Summary
Linked-table question types in AnthroCollect need to open a child form on top of a parent form, wait for the child to be completed or dismissed, and then return to the parent form exactly where it was — same page, same field state, same scroll position. This matches the behavior that existed in the original OMO repo running on top of ODK-X.
This PR fixes the root cause: the native Formulus app was destroying the parent form modal before opening the child form, making state restoration impossible.
Problem
The original
App.tsxmaintained a single formplayer modal instance. WhenopenFormplayerwas called while a modal was already visible, it explicitly closed the existing modal first:This meant:
Solution
Replace the single-modal design with a modal stack. Each
openFormplayercall pushes a new entry onto the stack. The parent modal stays mounted underneath the child modal. When the child closes, the parent becomes the top of the stack again and receives a focus notification so the form JS layer can react.Key concepts