fix: JSON Mode Resets Page State #4519
Merged
+12
−7
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.
What type of PR is this?
(REQUIRED)
What this PR does / why we need it:
(REQUIRED)
We have a cleanup function
clearPageState
which runs when we leave the recipe page. However, it actually runs when a particular component is unmounted, rather than the page itself. In most instances this is fine because the component isn't unmounted until leaving edit mode, except JSON mode unmounts the component too. This causes the page state to reset prematurely, which has some funky effects (namely instructions are no longer editable).This PR moves the cleanup method to the page component, ensuring it doesn't run until the user actually leaves the recipe page.
Which issue(s) this PR fixes:
(REQUIRED)
Fixes #4509 (comment)
Special notes for your reviewer:
(fill-in or delete this section)
Took some work to diagnose this one, but was otherwise a pretty simple fix.
Testing
(fill-in or delete this section)
Manually.