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
Execute BeforeEnter listeners starting with top parent. #7130
Conversation
ee646aa
to
e85a890
Compare
2ff214b
to
96fee64
Compare
d315dd7
to
b65f311
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 4 unresolved discussions, 0 of 1 LGTMs obtained (waiting on @bogdanudrescu, @caalador, and @Legioth)
flow-server/src/main/java/com/vaadin/flow/router/BeforeEvent.java, line 439 at r8 (raw file):
* @deprecated use {@link #getRerouteTargetType()} instead. */ @deprecated
It should be @Deprecated
flow-server/src/main/java/com/vaadin/flow/router/internal/AbstractNavigationStateRenderer.java, line 466 at r7 (raw file):
Previously, bogdanudrescu (Bogdan Udrescu) wrote…
Then may we leave it as it is? Inside
createChain...
we need to reverse it back and forth since there it's either created or it comes in with target first and we need to send the events the other way then we need to output it with target first, although it's create starting with root.
Could we just part them into two methods where one handles new chain creation and one handles a prepopulated one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 4 unresolved discussions, 0 of 1 LGTMs obtained (waiting on @bogdanudrescu, @caalador, and @Legioth)
flow-server/src/main/java/com/vaadin/flow/router/internal/AbstractNavigationStateRenderer.java, line 466 at r7 (raw file):
Previously, caalador wrote…
Could we just part them into two methods where one handles new chain creation and one handles a prepopulated one?
One moment, I'll make a bit of changes and add one more test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 4 unresolved discussions, 0 of 1 LGTMs obtained (waiting on @bogdanudrescu, @caalador, and @Legioth)
flow-server/src/main/java/com/vaadin/flow/router/internal/AbstractNavigationStateRenderer.java, line 466 at r7 (raw file):
Previously, bogdanudrescu (Bogdan Udrescu) wrote…
One moment, I'll make a bit of changes and add one more test.
Yes, we can do that too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 4 unresolved discussions, 0 of 1 LGTMs obtained (waiting on @bogdanudrescu, @caalador, and @Legioth)
flow-server/src/main/java/com/vaadin/flow/router/BeforeEvent.java, line 439 at r8 (raw file):
Previously, caalador wrote…
It should be
@Deprecated
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please ask someone else from the to also have a look.
Reviewed 3 of 3 files at r9.
Reviewable status: 1 unresolved discussion, 0 of 1 LGTMs obtained (waiting on @bogdanudrescu and @Legioth)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 7 unresolved discussions, 0 of 1 LGTMs obtained (waiting on @bogdanudrescu and @Legioth)
flow-server/src/main/java/com/vaadin/flow/router/BeforeEvent.java, line 445 at r9 (raw file):
/** * Get the route target for rerouting.
With his API addition, there will be one method called getRerouteTarget()
and one calledgetRerouteTargetType()
, and the JavaDoc for getRerouteTarget()
also says effectively ´gets the reroute target`. It could be good to write that this methods gets route target type for better consistency in the terminology.
flow-server/src/main/java/com/vaadin/flow/router/EventUtil.java, line 132 at r9 (raw file):
.flatMap(chainRoot -> collectBeforeEnterObserversStream( chainRoot.getElement(), getElements(childrenExclusions)))
Evaluating getElements(childrenExclusions)
inside the lambda is suboptimal as it leads to the childrenExclusions
stream being materialized multiple times. The subexpression could be lifted outside the flatMap
expression.
flow-server/src/main/java/com/vaadin/flow/router/internal/AbstractNavigationStateRenderer.java, line 82 at r9 (raw file):
private Postpone postponed = null; private LocationChangeEvent locationChangeEvent;
Not blocking, but maybe initialize this also explicitly to null
for clarity.
flow-server/src/main/java/com/vaadin/flow/router/internal/AbstractNavigationStateRenderer.java, line 196 at r9 (raw file):
// We're returning because the preserved chain is not ready to // be used as is, and requires client data requested within // `createOrRehandlePreserveOnRefreshComponent`. Once the data
Since method createOrRehandlerPreserveOnRefreshComponent
is renamed in the change, update also the comment to reduce confusion.
flow-server/src/main/java/com/vaadin/flow/router/internal/AbstractNavigationStateRenderer.java, line 593 at r9 (raw file):
/* * Check whether the eventHandler is the component itself ot a child of it.
Typo: "ot" -> "or"
flow-server/src/main/java/com/vaadin/flow/router/internal/AbstractNavigationStateRenderer.java, line 595 at r9 (raw file):
* Check whether the eventHandler is the component itself ot a child of it. */ private boolean isEqualsOrChild(BeforeEnterHandler eventHandler,
Method could be static and the name improved, since the method doesn't return true if the arguments are equal (but rather, if their contained elements are equal).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 7 unresolved discussions, 0 of 1 LGTMs obtained (waiting on @bogdanudrescu, @caalador, @joheriks, and @Legioth)
flow-server/src/main/java/com/vaadin/flow/router/BeforeEvent.java, line 445 at r9 (raw file):
Previously, joheriks (Johannes Eriksson) wrote…
With his API addition, there will be one method called
getRerouteTarget()
and one calledgetRerouteTargetType()
, and the JavaDoc forgetRerouteTarget()
also says effectively ´gets the reroute target`. It could be good to write that this methods gets route target type for better consistency in the terminology.
Done.
flow-server/src/main/java/com/vaadin/flow/router/EventUtil.java, line 132 at r9 (raw file):
Previously, joheriks (Johannes Eriksson) wrote…
Evaluating
getElements(childrenExclusions)
inside the lambda is suboptimal as it leads to thechildrenExclusions
stream being materialized multiple times. The subexpression could be lifted outside theflatMap
expression.
Done.
flow-server/src/main/java/com/vaadin/flow/router/internal/AbstractNavigationStateRenderer.java, line 82 at r9 (raw file):
Previously, joheriks (Johannes Eriksson) wrote…
Not blocking, but maybe initialize this also explicitly to
null
for clarity.
Done.
flow-server/src/main/java/com/vaadin/flow/router/internal/AbstractNavigationStateRenderer.java, line 196 at r9 (raw file):
Previously, joheriks (Johannes Eriksson) wrote…
Since method
createOrRehandlerPreserveOnRefreshComponent
is renamed in the change, update also the comment to reduce confusion.
Done.
flow-server/src/main/java/com/vaadin/flow/router/internal/AbstractNavigationStateRenderer.java, line 595 at r9 (raw file):
Previously, joheriks (Johannes Eriksson) wrote…
Method could be static and the name improved, since the method doesn't return true if the arguments are equal (but rather, if their contained elements are equal).
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 7 unresolved discussions, 0 of 1 LGTMs obtained (waiting on @bogdanudrescu, @caalador, @joheriks, and @Legioth)
flow-server/src/main/java/com/vaadin/flow/router/internal/AbstractNavigationStateRenderer.java, line 593 at r9 (raw file):
Previously, joheriks (Johannes Eriksson) wrote…
Typo: "ot" -> "or"
Done.
SonarQube analysis reported 3 issues Watch the comments in this conversation to review them. 2 extra issuesNote: The following issues were found on lines that were not modified in the pull request. Because these issues can't be reported as line comments, they are summarized here:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 3 of 3 files at r10.
Reviewable status: 1 unresolved discussion, 1 of 1 LGTMs obtained (waiting on @bogdanudrescu and @Legioth)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dismissed @vaadin-bot from a discussion.
Reviewable status: complete! all discussions resolved, 1 of 1 LGTMs obtained (waiting on @Legioth)
Fixes #4595
Route layouts and target component are created right before the event is fired. So if a parent layout
beforeEnter
redirects, then the rest of the layouts in the chain and the component target itself won't be created.Before this change the order of events was as follow:
After the change:
This PR also fixes the case when a route layout redirects to the navigation target currently navigating to.
This change is