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

Prevent router from some paths #325

Closed
abdonrd opened this issue Feb 20, 2019 · 5 comments · Fixed by #421
Closed

Prevent router from some paths #325

abdonrd opened this issue Feb 20, 2019 · 5 comments · Fixed by #421
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers hilla

Comments

@abdonrd
Copy link
Contributor

abdonrd commented Feb 20, 2019

How to prevent router to intercept some paths?

Example:

My landing page use Vaadin Router, but I also have a /documentation path that I don't want to be handled by the router, because the documentation is another static app.

With the current behavior, and using the fallback route (path: '(.*)'), when you click on a documentation link (<a href="/documentation">Documentation</a>), you see the fallback route instead of the documentation static app.

@vlukashov vlukashov added the enhancement New feature or request label Jul 30, 2019
@vlukashov vlukashov added the good first issue Good for newcomers label Dec 13, 2019
@vlukashov
Copy link

vlukashov commented Dec 13, 2019

A community member has suggested a solution:

  • to exclude individual links, add an vaadin-router-ignore attribute on the <a> tag
    <a href="/some/static/page" vaadin-router-ignore>External Page</a>
    This requires a small change in the CLICK navigation trigger.
  • to exclude a group of links at once, create a route with a special action:
    routes = [
      // this may be the first route in the config
      {
        path: '/pattern/to/exclude/(.*)',
        action: (ctx, commands) => {
          window.location.pathname = ctx.pathname;
        }
      },
      ...
    ];

ToDo:

@miladkdz miladkdz self-assigned this Dec 13, 2019
@miladkdz
Copy link
Contributor

miladkdz commented Dec 13, 2019

Are we sure about the attribute name? I feel that's it is too long. How about just router-ignore?

@vlukashov
Copy link

Are we sure about the attribute name? I feel that's it is too long. How about just router-ignore?

Yep, vaadin-router-ignore sounds a bit too long. The reason why I do not like the short ignore option is that it's lacking context:

<a href="/admin" ignore>Admin</a>

Should this link be ignored?

Some other options I have in mind are:

  • vaadin-ignore
  • router-ignore

Would any of these be better?

@miladkdz
Copy link
Contributor

The reason I lean towards router-ignore is that first of all it has context and second we don't have vaadin in any other attributes. So It's more consistent with the other attributes.

miladkdz pushed a commit to miladkdz/vaadin-router that referenced this issue Dec 13, 2019
vlukashov pushed a commit that referenced this issue Jan 8, 2020
vlukashov pushed a commit that referenced this issue Jan 8, 2020
Follow-up on #421, related to #325

fix linter issue
haijian-vaadin pushed a commit that referenced this issue Jan 9, 2020
Follow-up on #421, related to #325

fix linter issue
@klauss194
Copy link

Hi,
I have 2 html files -> index.html ( vaadin + lit ) and chat.html ( react ). the above doesn't seem to work as when I navigate manually from 1 app to the other -> I still get a " route not found " error.

Can anyone help with a bit of guidance how to ignore navigating from 1html file to another from being picked up by the router ?

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

Successfully merging a pull request may close this issue.

4 participants