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

router-ignore broken #822

Open
bsutton opened this issue Dec 5, 2022 · 0 comments
Open

router-ignore broken #822

bsutton opened this issue Dec 5, 2022 · 0 comments

Comments

@bsutton
Copy link

bsutton commented Dec 5, 2022

vaadin 23.2.0
I've been having an issue with html tag anchor with a in-page link not working in raw html sent to the browser.

I've raised a stackoverflow issue thinking that I was doing something wrong but I now think it might be a bug.

https://stackoverflow.com/questions/74634530

<a href="#how-to-resolve-the-problem" router-ignore="true" vaadin-router-ignore="true">How to resolve the problem</a>

<h1 id="how-to-resolve-the-problem" >How to resolve the problem</h1>

The problem is that when a user clicks the anchor link vaadin navigates back to the home page rather than simply scrolling down the page to the h1 tag.

I refer you to this issue where the feature was discussed.

#421

You can see from the conversation that original intent was for the attribute to be called 'vaadin-router-ignore' but was ultimately renamed 'router-ignore'.

In tracing through the client side code I see the click event passing through a couple key pieces of code:

  1. click.js line: 72

this function triggers as expected and the vaadinRouterGlobalClickHandler returns.

  // ignore the click if the <a> element has the 'router-ignore' attribute
  if (anchor.hasAttribute('router-ignore')) {
    return;
  }

When the call to vaadinRouterGlobalClickHandler returns we then see vaadinRouterGlobalPopstateHandler being called

  1. popstate.js from line 18
function vaadinRouterGlobalPopstateHandler(event) {
  if (event.state === 'vaadin-router-ignore') {
    return;
  }
  const {pathname, search, hash} = window.location;
  fireRouterEvent('go', {pathname, search, hash});
}

Note that this refers to the name 'vaadin-router-ignore'.

At this point the event.state is null so I'm not certain whether this is meant to be part of the 'a' tag processing so I wonder if there are two bugs here, 1) the incorrect usage of vaadin-router-ignore and the fact that vaadinRouterGlobalPopstateHandler is called after vaadinRouterGlobalClickHandler returns.

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

No branches or pull requests

1 participant