Skip to content

Don't re-render diff when changing scroll sync #1089

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

Merged
merged 1 commit into from
Jun 19, 2025

Conversation

Mr0grog
Copy link
Member

@Mr0grog Mr0grog commented Jun 19, 2025

When toggling whether scrolling was sync'd, the diff views used to re-render and reset their scrolling to the top (so you couldn't, for example, scroll to a position, unsync, and then scroll more on one side). This was happening because changing the setting (re-)creates a new set of transforms, which are different props for the SandboxedHtmlView, which then re-sets the srcdoc property on its iframe. This solves the issue by only re-setting srcdoc if we are actually changing it.

Ideally we'd also do some caching of transforms so that creating one with the same arguments returns an identical transformer function, but that's a whole other ball of wax with memory management, and is not the only way we can cause this sort of problem. This fix is dumber, but probably more resilient.

When changing whether scrolling was sync'd, it would cause the diff views to re-render and reset their scrolling to the top (so you couldn't, for example, scroll to a position, unsync, and then scroll more on one side). This was happening because changing the setting (re-)creates a new set of transforms, which are different props for the `SandboxedHtmlView`, which then re-sets the `srcdoc` property on its `iframe`. This solves the issue by only re-setting `srcdoc` if we are actually changing it. (Ideally we'd also do some caching so that creating a transform with the same arguments returns an idental transformer function, but that's a whole other ball of wax with memory management, and is not the only way we can cause this sort of problem. This fix is dumber, but probably more resilient.)
@Mr0grog Mr0grog merged commit 7f9a76d into main Jun 19, 2025
5 checks passed
@Mr0grog Mr0grog deleted the unsyncing-scrolling-is-just-not-a-fundamental-change branch June 19, 2025 01:22
@github-project-automation github-project-automation bot moved this from Inbox to Done in Web Monitoring Jun 19, 2025
Mr0grog added a commit that referenced this pull request Jun 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

1 participant