Skip to content

Commit

Permalink
Fix scroll position (#97294)
Browse files Browse the repository at this point in the history
  • Loading branch information
DustyReagan authored Dec 10, 2024
1 parent 7ec63a7 commit 1ebd264
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions client/reader/onboarding/subscribe-modal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,21 @@ const SubscribeModal: React.FC< SubscribeModalProps > = ( { isOpen, onClose } )
}
}, [ displayedRecommendations, selectedSite ] );

const handleItemClick = useCallback( ( site: CardData ) => {
setSelectedSite( site );
}, [] );
const handleItemClick = useCallback(
( site: CardData ) => {
// Only reset scroll position if selecting a different site.
if ( site.feed_ID !== selectedSite?.feed_ID ) {
const previewContainer = document.querySelector(
'.subscribe-modal__preview-stream-container'
);
if ( previewContainer ) {
previewContainer.scrollTop = 0;
}
}
setSelectedSite( site );
},
[ selectedSite ]
);

const follows = useSelector( getReaderFollows );

Expand Down

0 comments on commit 1ebd264

Please sign in to comment.