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

AfterNavigationEvent should give access to RouteParameters as well #9993

Closed
Tracked by #4379
mvysny opened this issue Feb 9, 2021 · 5 comments · Fixed by #17817
Closed
Tracked by #4379

AfterNavigationEvent should give access to RouteParameters as well #9993

mvysny opened this issue Feb 9, 2021 · 5 comments · Fixed by #17817

Comments

@mvysny
Copy link
Member

mvysny commented Feb 9, 2021

There's BeforeEvent.getRouteParameters() but there is no such AfterNavigationEvent.getRouteParameters().

Versions:

- Vaadin / Flow version: 14.5.0.alpha3
@Legioth
Copy link
Member

Legioth commented Feb 9, 2021

Could you also describe a use case where this information would be useful?

@pleku
Copy link
Contributor

pleku commented Feb 9, 2021

Did you have a specific case in mind where those would be needed?

Looking at the code, it should be fairly trivial to include the parameters into https://github.com/vaadin/flow/blob/master/flow-server/src/main/java/com/vaadin/flow/router/internal/AbstractNavigationStateRenderer.java#L238 as the parameters are available there. But creating those in https://github.com/vaadin/flow/blob/master/flow-server/src/main/java/com/vaadin/flow/server/BootstrapUtils.java#L160 requires some effort or code duplication to create the parameters.

@mvysny
Copy link
Member Author

mvysny commented Feb 9, 2021

Did you have a specific case in mind where those would be needed?

Nothing specific in mind; it's only a personal preference of listening to AfterNavigationEvent and init'ing the view there: since AfterNavigationEvents are final and can not be redirected, the view init code's work won't go into waste. Maybe it is foolish from my side.

I was just curious why AfterNavigationEvent lacks stuff which BeforeEvent contains. Looks a bit strange to me since both events are quite similar (they're both navigational events).

@jcgueriaud1
Copy link
Contributor

I got the same "problem". In my Vaadin application (done in Vaadin 14.x pre 14.5), I'm using AfterNavigation to highlight the menu like it's explained in the documentation:
https://vaadin.com/docs/v14/flow/routing/tutorial-routing-lifecycle/#afternavigationevent
I can still using the getLocation or probably highlight the menu in BeforeEnter.

From the documentation:

This event is typically used to update various parts of the UI after the actual navigation is complete. Examples include adjusting the content of a breadcrumb component and visually marking the active menu item as active.

The breadcrumb could need the parameter like: Home>Books>Edit Book 3

@vaadin-bot
Copy link
Collaborator

This ticket/PR has been released with Vaadin 24.3.0.alpha1 and is also targeting the upcoming stable 24.3.0 version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment