mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-11-09 05:26:24 +09:00
fix: canvas autoscroll issue when selecting instances (#4174)
## Description closes #4169 ## Steps for reproduction Shoud be tested well as having various scroll/resize/mutation obserevers we have, everything can cause infinite cycle ## Code Review - [ ] hi @kof, I need you to do - conceptual review (architecture, feature-correctness) - detailed review (read every line) - test it on preview ## Before requesting a review - [ ] made a self-review - [ ] added inline comments where things may be not obvious (the "why", not "what") ## Before merging - [ ] tested locally and on preview environment (preview dev login: 5de6) - [ ] updated [test cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md) document - [ ] added tests - [ ] if any new env variables are added, added them to `.env` file
This commit is contained in:
1 parent
334caf4ec6
commit
34cd2104d2
1 file changed
+8
@@ -179,6 +179,12 @@ const recalculate = () => {
|
||||
}
|
||||
}
|
||||
|
||||
// If most elements are collapsed at the next step, scrollHeight becomes equal to clientHeight,
|
||||
// which resets the scroll position. To prevent this, we set the document's height to the current scrollHeight
|
||||
// to preserve the scroll position.
|
||||
const preserveHeight = document.documentElement.style.height;
|
||||
document.documentElement.style.height = `${document.documentElement.scrollHeight}px`;
|
||||
|
||||
// Now combine all operations in batches.
|
||||
|
||||
// 1. Remove all collapsed attributes
|
||||
@@ -222,6 +228,8 @@ const recalculate = () => {
|
||||
for (const [element, value] of collapsedElements.entries()) {
|
||||
element.setAttribute(collapsedAttribute, value);
|
||||
}
|
||||
|
||||
document.documentElement.style.height = preserveHeight;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user