fix: Anchor - The replace attribute causes no scrolling animation (#49136)

Co-authored-by: dengxia <dengxia@tanqingsk.com>
This commit is contained in:
小邓 2024-05-30 20:49:30 +08:00 committed by GitHub
parent 72791d16f3
commit a59081ea55
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -42,12 +42,12 @@ const AnchorLink: React.FC<AnchorLinkProps> = (props) => {
}, [href]);
const handleClick = (e: React.MouseEvent<HTMLAnchorElement, MouseEvent>) => {
onClick?.(e, { title, href });
scrollTo?.(href);
if (replace) {
e.preventDefault();
window.location.replace(href);
}
onClick?.(e, { title, href });
scrollTo?.(href);
};
// =================== Warning =====================