-
Notifications
You must be signed in to change notification settings - Fork 14
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
Fix links with filters not marked as active in the menu #187
base: main
Are you sure you want to change the base?
Conversation
Hey @susanu thanks for the PR . Unfortunately I don't think this is the right approach. My understanding of this issue is that If we follow your approach, let's say my menu is: Let me know if I am on track here or if you think I am missing something. Cheers |
Yes, they are the same page, it's just a filter with a default value
I just tested again with a normal link on the menu but with filters active and this PR would fail in this case. I think the right approach would be to treat menu dropdown and menu dropdown item differently when checking for the active one. |
Not sure if this would work, but maybe adding an option to the menu item to decide if the menu item matches the url with parameters (current behavior) or if it should keep parameters/hash and validate the current url with them? Like I think that could cover both scenarios with a simple let url = window.location.href;
// only strip parameters if set by developer
if(el.getAttribute('match-active-full-url') === false) {
url = url.split("#")[0].split("?")[0];
} Something like: Do you think this could work ? Cheers |
Lets take an example: Lets assume i want 3 links In this case, only check menu dropdown item (the ones with actual links) and not menu dropdown.
After checking the active menu item, then mark parent dropdown as active as well. Let me know if i speak nonsense here or i am overthinking. |
Hey @susanu , nice example. So in your example, doing a TLDR; here, what you think is missing is a way to tell what parameters to keep and what to remove ? I think we can easily adapt the example I gave previously with the
Would this work for your scenario ? Storing filter values inside the menu is a no-no in my opinion. Let's try to keep the focus on "match route links with urls" and forget the word filters. Let's assume there are just different types of urls (or different ways a url can be presented), and try to come up with something that does not transform this into a BIG thing, and keep it KISS so we can think in merging something like this. Let me know what you think. |
Looks good to me. Should we close this PR and create another one? |
This PR doesn't have much, we can just change it since we already have all the conversation here. How would the javascript part for this work ? Would it be a big mess ? I think it will be quite simple but haven't really got deep into this subject. |
Hi,
I have some links in the menu with filters applied, the problem is that they don't appear as active in the menu when you click on these links.
This pull requesut would solve the issue.
Thanks!