Skip to content

Commit 3830b5b

Browse files
authored
docs: remove smooth behavior from SideNav autoscroll (adobe#9828)
* docs: remove smooth behavior from SideNav autoscroll * only scroll on mount
1 parent 2fd3c81 commit 3830b5b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

packages/dev/s2-docs/src/Nav.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,16 +256,18 @@ export function SideNavItem(props) {
256256

257257
export function SideNavLink(props) {
258258
let linkRef = useRef<HTMLAnchorElement | null>(null);
259+
let shouldAutoScrollOnMount = useRef(props.isSelected);
259260
let selected = useContext(SideNavContext);
260261
let {isExternal, ...linkProps} = props;
261262

262263
useEffect(() => {
263264
let link = linkRef.current;
264-
if (!link || !props.isSelected) {
265+
if (!link || !props.isSelected || !shouldAutoScrollOnMount.current) {
265266
return;
266267
}
267268

268-
link.scrollIntoView({block: 'start', behavior: 'smooth'});
269+
shouldAutoScrollOnMount.current = false;
270+
link.scrollIntoView({block: 'start'});
269271
}, [props.isSelected]);
270272

271273
return (

0 commit comments

Comments
 (0)