Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

avoid scroll when restoring focus

Roman Pominov8e578649b670
diff --git a/apps/designer/app/designer/shared/tree/tree.tsx b/apps/designer/app/designer/shared/tree/tree.tsx
index 8e1367fb3b..00410a9790 100644
--- a/apps/designer/app/designer/shared/tree/tree.tsx
+++ b/apps/designer/app/designer/shared/tree/tree.tsx
@@ -362,7 +362,7 @@ const useKeyboardNavigation = ({
`[data-item-button-id="${instanceId}"]`
);
if (itemButton instanceof HTMLElement) {
- itemButton.focus();
+ itemButton.focus({ preventScroll: true });
}
},
[rootRef]
@@ -379,9 +379,6 @@ const useKeyboardNavigation = ({
// If we've lost focus due to a root update, we want to get it back.
// This can happen when we delete an item or on drag-end.
- //
- // @todo: This causes selected item to scroll into view when you expand/collapse some other item.
- // Need avoid this somehow.
if (
isRootChanged &&
haveFocus === false &&