Skip to content

Commit 49ca9a5

Browse files
Fix scrolling to top: scroll smoothing to center (#79)
This PR aims to fix scrolling to top: scroll smoothing to center
1 parent 5ee48b8 commit 49ca9a5

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Fixed
11+
12+
- instant scrolling to top on active `PanelSideBarItem`; scrolling smoothing to center instead.
13+
1014
## [5.3.0] - 2025-09-30
1115

1216
### Fix

src/lib/Layout/PanelSideBarLayout/PanelSideBar/PanelSideBarItem.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,14 @@ const PanelSideBarItem = <TPanelItemId extends string, TPanelItem>(props: PanelS
5050
const collapsedWithIcon = isIconShownOnSidebarCollapse && !isSidebarOpen;
5151

5252
useEffect(() => {
53-
if (scrollToActiveItemRef.current && isActive) {
54-
scrollToActiveItemRef.current.scrollIntoView();
53+
const currentItem = scrollToActiveItemRef.current;
54+
55+
if (!item.active || !currentItem) {
56+
return;
5557
}
56-
}, [isActive]);
58+
59+
currentItem.scrollIntoView({ behavior: "smooth", block: "center" });
60+
}, [scrollToActiveItemRef, item.active]);
5761

5862
return (
5963
<>

0 commit comments

Comments
 (0)