fix: side bar favorited list cannot scroll (#1606)

Co-authored-by: sheben404 <sheben404@gmail.com>
This commit is contained in:
Himself65
2023-03-17 19:32:00 -04:00
committed by GitHub
parent b6407f99c4
commit 74fc43020a

View File

@@ -49,8 +49,15 @@ const FavoriteList: React.FC<FavoriteListProps> = ({
() => pageMeta.filter(p => p.favorite && !p.trash), () => pageMeta.filter(p => p.favorite && !p.trash),
[pageMeta] [pageMeta]
); );
return ( return (
<MuiCollapse in={showList}> <MuiCollapse
in={showList}
style={{
maxHeight: 300,
overflowY: 'auto',
}}
>
{favoriteList.map((pageMeta, index) => { {favoriteList.map((pageMeta, index) => {
const active = router.query.pageId === pageMeta.id; const active = router.query.pageId === pageMeta.id;
return ( return (
@@ -58,6 +65,11 @@ const FavoriteList: React.FC<FavoriteListProps> = ({
<StyledSubListItem <StyledSubListItem
data-testid={`favorite-list-item-${pageMeta.id}`} data-testid={`favorite-list-item-${pageMeta.id}`}
active={active} active={active}
ref={ref => {
if (ref && active) {
ref.scrollIntoView({ behavior: 'smooth' });
}
}}
onClick={() => { onClick={() => {
if (active) { if (active) {
return; return;