ScrollableList: clear scrollData useMemo if scrollKey changes

This commit is contained in:
Alex Gleason 2022-06-02 20:40:14 -05:00
parent 36fb7fea7d
commit 8baa4cd262
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7

View file

@ -84,7 +84,7 @@ const ScrollableList = React.forwardRef<VirtuosoHandle, IScrollableList>(({
// Preserve scroll position
const scrollDataKey = `soapbox:scrollData:${scrollKey}`;
const scrollData: SavedScrollPosition | null = useMemo(() => JSON.parse(sessionStorage.getItem(scrollDataKey)!), []);
const scrollData: SavedScrollPosition | null = useMemo(() => JSON.parse(sessionStorage.getItem(scrollDataKey)!), [scrollDataKey]);
const topIndex = useRef<number>(scrollData ? scrollData.index : 0);
const topOffset = useRef<number>(scrollData ? scrollData.offset : 0);