Skip to content

Conversation

@WoodingMP
Copy link
Contributor

In our application we've got a navigation bar that sits about the RouterView in our App component, the idea being that this navigation bar is available on every page, and has the logic to navigate between them while remaining visible the whole time.

We have a pain point with the current router implementation when navigating between pages in that anytime you use $router.to, focus automatically gets passed to the RouterView and then along to the page component. For us this means that our nav gets unfocused every time we swap pages rather than what we need which is for the nav bar to remain in focus until you scroll down into a page.

To support this use case, I've added a check for a passFocus option when navigating. This won't affect the current logic when unused, but if set to false as part of the router options, the current focus will not change when navigating.

Example:
this.$router.to('home', {id: 123456}, {passFocus: false});

This would prevent us needing to constantly fight the current focus and try and refocus the nav when going between pages

@github-actions
Copy link

Test Results: ✅ PASSED

Run at: 2025-07-30T12:57:08.134Z

Summary:
passed: 665 failed: 0 of 665 tests

@michielvandergeest
Copy link
Collaborator

hey @WoodingMP, thanks for adding this! This feature has been on our list as well, as we were having the same use case where the menu is supposed to stay open while navigating to a new page in the background, and should only close when the user clicks right. We just didn't get to implementing it yet

And kudos for adding some docs at the same time as well 👍

Just let me take a minute to think about the naming of the passFocus attribute. I think I like it 🙂 but want to make it's the best name going forward

@WoodingMP
Copy link
Contributor Author

Thanks @michielvandergeest! I leave the naming in your capable hands it was just the first thing that popped to mind haha

Copy link
Collaborator

@michielvandergeest michielvandergeest left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

I think the name you came up with, is perfectly in line with the existing inHistory and keepAlive, so passFocus feels like a goon option to me.

Thanks again for adding this functionality 🙂

@michielvandergeest michielvandergeest changed the base branch from master to dev August 4, 2025 05:31
@michielvandergeest michielvandergeest merged commit dfc18b9 into lightning-js:dev Aug 4, 2025
3 checks passed
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

Successfully merging this pull request may close these issues.

2 participants