Skip to content

Commit

Permalink
fix: more robust Server route check (#19063)
Browse files Browse the repository at this point in the history
* fix: more robust Server route check

Make server route validation
not use path but element instead.

* Update flow-server/src/main/resources/com/vaadin/flow/server/frontend/Flow.tsx

Co-authored-by: Tomi Virtanen <tltv@vaadin.com>

---------

Co-authored-by: Tomi Virtanen <tltv@vaadin.com>
  • Loading branch information
caalador and tltv committed Mar 28, 2024
1 parent f817aa0 commit b6522bf
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ function navigateEventHandler(event) {

// if navigation event route targets a flow view do beforeEnter for the
// target path. Server will then handle updates and postpone as needed.
if(matched && matched.length > 0 && matched[matched.length - 1].route.path === "/*") {
// @ts-ignore
if(matched && matched.filter(path => path.route?.element?.type?.name === Flow.name).length >= 1) {
if (mountedContainer?.onBeforeEnter) {
// onBeforeEvent call will handle the Flow navigation
mountedContainer.onBeforeEnter(
Expand Down Expand Up @@ -309,7 +310,8 @@ export default function Flow() {
// flow from the view
// If we are going to a non Flow view then we need to clean the Flow
// view from the dom as we will not be getting a uidl response.
if(matched && matched[matched.length - 1].route.path !== "/*") {
// @ts-ignore
if(matched && matched.filter(path => path.route?.element?.type?.name === Flow.name).length == 0) {
mountedContainer?.parentNode?.removeChild(mountedContainer);
mountedContainer = undefined;
}
Expand Down

0 comments on commit b6522bf

Please sign in to comment.