Skip to content

Commit a14d013

Browse files
authored
doc: onNavigate follow-up (#77805)
Fix the logic when user explicitly wants to leave the page but navigation is blocked.
1 parent 95b2c19 commit a14d013

File tree

1 file changed

+8
-8
lines changed
  • docs/01-app/04-api-reference/02-components

1 file changed

+8
-8
lines changed

docs/01-app/04-api-reference/02-components/link.mdx

+8-8
Original file line numberDiff line numberDiff line change
@@ -1362,11 +1362,11 @@ export function CustomLink({ children, ...props }: CustomLinkProps) {
13621362
return (
13631363
<Link
13641364
onNavigate={(e) => {
1365-
if (isBlocked) {
1365+
if (
1366+
isBlocked &&
1367+
!window.confirm('You have unsaved changes. Leave anyway?')
1368+
) {
13661369
e.preventDefault()
1367-
if (!window.confirm('You have unsaved changes. Leave anyway?')) {
1368-
e.preventDefault()
1369-
}
13701370
}
13711371
}}
13721372
{...props}
@@ -1389,11 +1389,11 @@ export function CustomLink({ children, ...props }) {
13891389
return (
13901390
<Link
13911391
onNavigate={(e) => {
1392-
if (isBlocked) {
1392+
if (
1393+
isBlocked &&
1394+
!window.confirm('You have unsaved changes. Leave anyway?')
1395+
) {
13931396
e.preventDefault()
1394-
if (!window.confirm('You have unsaved changes. Leave anyway?')) {
1395-
e.preventDefault()
1396-
}
13971397
}
13981398
}}
13991399
{...props}

0 commit comments

Comments
 (0)