Skip to content

Removes onNavigate from transition scope #78605

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: canary
Choose a base branch
from

Conversation

lourd
Copy link

@lourd lourd commented Apr 27, 2025

What?

Fixes a bug in the Link component where state updates inside an onNavigate callback aren't committed.

Why?

onNavigate is intended to provide a way to create transition animations and pending states during navigation, but state updates within the handler weren't taking effect due to them being batched with the page state change transition. This made it impossible to properly implement pending UI states using this API, forcing developers to fall back to the less appropriate onClick handler (which had its own issues like triggering when opening links in new tabs).

See this comment on #78361 for details.

How?

By removing the onNavigate handler from the transition scope that the navigation action is called within, user's are given the option to determine whether their state update should be priority — not batched with the route update — or a background update — batched with the route update, by whether or not they call startTransition themselves in the callback they pass to onNavigate.

Calling preventDefault() on the passed event works as before.

Fixes #78361

@ijjk
Copy link
Member

ijjk commented Apr 27, 2025

Allow CI Workflow Run

  • approve CI run for commit: ae9cce8

Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer

1 similar comment
@ijjk
Copy link
Member

ijjk commented Apr 27, 2025

Allow CI Workflow Run

  • approve CI run for commit: ae9cce8

Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

State update in onNavigate handler never getting committed
2 participants