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

NavLinks with parentheses in the path do not set active className #5584

Closed
esiegel opened this issue Oct 3, 2017 · 3 comments
Closed

NavLinks with parentheses in the path do not set active className #5584

esiegel opened this issue Oct 3, 2017 · 3 comments

Comments

@esiegel
Copy link
Contributor

esiegel commented Oct 3, 2017

The active link for NavLinks are not created for paths that have parentheses. It seems that the underlying regex that is generated by path-to-regex does not escape the parentheses in the generated regex and instead interprets it as a match group. Notice in the example how the active classname is not set for the about component.

Version

4.1.1

Test Case

https://codesandbox.io/s/n55VljYk7

Steps to reproduce

Create a NavLink component whose path has parentheses, ie /some/path (1).

Expected Behavior

When the component is routed to and rendering the active classname should be added.

Actual Behavior

The classname is missing.

I wasn't sure if this was expected behavior in the underlying path-to-regex, so I figured it'd be best to ask here first.

@esiegel
Copy link
Contributor Author

esiegel commented Oct 3, 2017

Oops, didn't save the Test Case:

https://codesandbox.io/s/qqov6y0w3q

@pshrmn
Copy link
Contributor

pshrmn commented Oct 6, 2017

If you want to submit a PR for this, I think that you would need to modify the value passed to path by escaping any of path-to-regexp's "special" characters.

@esiegel
Copy link
Contributor Author

esiegel commented Oct 6, 2017

Thanks for the info. I did a poor job searching path-to-regexp's issue list. I'll try my hand at tackling this issue. Should be easy enough.

@timdorr timdorr closed this as completed in c3d453e Oct 6, 2017
@lock lock bot locked as resolved and limited conversation to collaborators Jan 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants