doc: onNavigate follow-up (#77805)

Fix the logic when user explicitly wants to leave the page but
navigation is blocked.
This commit is contained in:
Jude Gao
2025-04-04 07:53:45 +08:00
committed by GitHub
parent 95b2c193d7
commit a14d013766
@@ -1362,11 +1362,11 @@ export function CustomLink({ children, ...props }: CustomLinkProps) {
return (
<Link
onNavigate={(e) => {
if (isBlocked) {
if (
isBlocked &&
!window.confirm('You have unsaved changes. Leave anyway?')
) {
e.preventDefault()
if (!window.confirm('You have unsaved changes. Leave anyway?')) {
e.preventDefault()
}
}
}}
{...props}
@@ -1389,11 +1389,11 @@ export function CustomLink({ children, ...props }) {
return (
<Link
onNavigate={(e) => {
if (isBlocked) {
if (
isBlocked &&
!window.confirm('You have unsaved changes. Leave anyway?')
) {
e.preventDefault()
if (!window.confirm('You have unsaved changes. Leave anyway?')) {
e.preventDefault()
}
}
}}
{...props}