Skip to content
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

Ability to set defaultHrefOpts globally #614

Closed
cloakedninjas opened this issue Jun 11, 2020 · 3 comments
Closed

Ability to set defaultHrefOpts globally #614

cloakedninjas opened this issue Jun 11, 2020 · 3 comments
Labels

Comments

@cloakedninjas
Copy link

I've found an issue whereby when a user enters the site with an anchor link in the URL domain.com/app/page#section The anchor part #section is appended to all URLs being output by ui-sref e.g. domain.com/app/home#section & domain.com/app/contact#section

By stepping through the library code, I found that the root state {state: ''} is being given the param:

params: {
  '#': Param(...)
}

And then in stateService.href() that param is inherited all the way down my chain of states

I'm not sure if this is a bug, something is misconfigured, or an issue with the app I'm working with but I have found that if I change the default value inherit: true to false this issue goes away.

"@uirouter/angular": "^6.0.1",
"@uirouter/angular-hybrid": "^10.0.1",
"@uirouter/angularjs": "^1.0.25",
"@uirouter/core": "^6.0.4",
"@uirouter/rx": "^0.6.5",

(any pointers appreciated)

@stale
Copy link

stale bot commented Dec 9, 2020

This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs.

This does not mean that the issue is invalid. Valid issues
may be reopened.

Thank you for your contributions.

@stale stale bot added the stale label Dec 9, 2020
@christopherthielen
Copy link
Member

could you write a transition hook to clear the parameter on startup?

  router.transitionService.onBefore({ from: "" }, transition => {
    const params = transition.params();
    if (params["#"] !== null) {
      const targetState = transition
        .targetState()
        .withParams({ ...params, "#": null });
      return transition.redirect(targetState);
    }
  });

Since it's the initial transition, the router won't change the URL, but it should be cleared when the user follows an UISref

@stale
Copy link

stale bot commented Jun 14, 2021

This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs.

This does not mean that the issue is invalid. Valid issues
may be reopened.

Thank you for your contributions.

@stale stale bot added the stale label Jun 14, 2021
@stale stale bot closed this as completed Jun 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants