Skip to content

Add goto options to Navigation object and/or offer a way to alter a navigation in progress #11585

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
GauBen opened this issue Jan 10, 2024 · 2 comments
Labels
feature / enhancement New feature or request

Comments

@GauBen
Copy link
Contributor

GauBen commented Jan 10, 2024

Describe the problem

I'm currently doing something very hacky because I cannot update the huge number of links on a page:

beforeNavigate(async ({ to, type, cancel }) => {
  if (
    (type === 'link' || type === 'goto') &&
    addTokenOnNavigation
  ) {
    const redirect = new URL(to.url);
    redirect.searchParams.set('token', data.token);
    cancel();             // Cancel original navigation
    await goto(redirect); // Navigate to the altered url
  }
});

This has many issues, but most importantly, there is no way to forward goto/link options such as noScroll/ data-sveltekit-noscroll.

Describe the proposed solution

Many solutions would solve my issue:

  1. Add an options prop to Navigation, mirroring goto.options structure.
  2. Add a rewrite function to BeforeNavigate, that basically does cancel+goto, and preserves all options

Alternatives considered

None

Importance

would make my life easier

Additional Information

No response

@GauBen GauBen changed the title Add goto options to Navigation object and offer a way to alter a navigation in progress Add goto options to Navigation object and/or offer a way to alter a navigation in progress Jan 10, 2024
@GauBen
Copy link
Contributor Author

GauBen commented Jan 10, 2024

Somewhat related to #11223

@GauBen
Copy link
Contributor Author

GauBen commented Jan 10, 2024

Just saw the new reroute hook! It won't work here as I want the edit to be visible in the address bar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature / enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants