USACE / groundwork

React Components for USACE Applications
https://usace.github.io/groundwork
4 stars 0 forks source link

Button href intercepts new tab links for files #92

Closed krowvin closed 1 month ago

krowvin commented 1 month ago

Working on using the

<Button href="/some/path/to/file.pdf">My File</Button>

Causes redux to fail finding the file (Returns you the 404 Component/page from the router)

If the PDF is in mvn-wm-public\public\reports\file.pdf

I would think it should be able to find it?

If i set an <a> tag to this <a href="\reports\file.pdf">Open my file in new tab</a> It works as expected.

Which makes me think redux is intercepting the file.

Am I missing something with the route-bundle that should be updated to include these static data files in the routing?

Example site this happened on for comparison on config/see if we missed something

https://github.com/usace/mvn-wm-web

willbreitkreutz commented 1 month ago

@krowvin yeah, we intercept all clicks and try and determine if they should be handled by the router or not. I'm surprised the a tag example works, i'm guessing it's because the slashes are backwards and you are on windows, i can't get that to work on my machine. Luckily there is an easy fix.

add target="_blank" to open in a new tab (without it you navigate to the file)

or add rel="_external" as a prop, and the nav helper will ignore it

krowvin commented 1 month ago

Ah!

Sorry yes we had to add the target="_blank" and for whatever reason I forgot to add that in my initial issue.

But the rel="_external" was what I was looking for if you wanted a link to stay on the same page for opening a document in the same tab for example.