fix bug linking directly to a specific list
This commit is contained in:
parent
8068a1d260
commit
c1012e57d5
1 changed files with 11 additions and 1 deletions
|
@ -411,8 +411,18 @@ function ClosetList({ closetList, isCurrentUser, showHeading }) {
|
|||
return aName.localeCompare(bName);
|
||||
});
|
||||
|
||||
// When this mounts, scroll it into view if it matches the location hash.
|
||||
// This works around the fact that, while the browser tries to do this
|
||||
// natively on page load, the list might not be mounted yet!
|
||||
const anchorId = `list-${closetList.id}`;
|
||||
React.useEffect(() => {
|
||||
if (document.location.hash === "#" + anchorId) {
|
||||
document.getElementById(anchorId).scrollIntoView();
|
||||
}
|
||||
}, [anchorId]);
|
||||
|
||||
return (
|
||||
<Box id={`list-${closetList.id}`}>
|
||||
<Box id={anchorId}>
|
||||
{showHeading && (
|
||||
<Heading3
|
||||
marginBottom="2"
|
||||
|
|
Loading…
Reference in a new issue