Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
**Problem:** When scrolling the canvas in the hydrogen demo project, the canvas intermittently freezes up for 100ms. Turns out the reason is that the hydrogen Link component is mounting elements to the screen when they become visible. And we use a MutationObserver to listen to elements being mounted / unmounted to trigger a dom-sampler re-run. We disable the MutationObserver for continuous interactions with set elementsToRerender, but the canvas scrolling interaction did not set elementsToRerender. `elementsToRerender` has been one of those editor state variables that is always default value in the unpatchedEditorState, and we only set it to an actual value in the patchedEditorState using patch commands from the strategy codebase. We talked about having some sort of safeguard in place that makes sure that in the unpatchedEditorState these values are kept at their default. **Fix:** I think this PR solves both problems: - a new `resetUnpatchedEditorTransientFields` function resets the unpatchedEditorState's `elementsToRerender` field to `rerender-all-elements` - `SCROLL_CANVAS` sets unpatchedEditorState's `elementsToRerender` to `[]` meaning the dom-walker will not interfere with the scroll performance. - because unpatchedEditorState elementsToRerender is reset at the end of every dispatch, the change in SCROLL_CANVAS amounts to a transient setting, very similar to how the editor state patches emitted by the strategies work. so we make sure that: 1. by the end of the dispatch, the UnpatchedEditorState's "transient" fields are reset 2. non-strategy interactions can set these fields when they need to **Manual Tests:** I hereby swear that: - [x] I opened a hydrogen project and it loaded - [x] I could navigate to various routes in Preview mode
- Loading branch information