-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: queued navigate with React Router (#19985)
Fixes #19839 --------- Co-authored-by: caalador <[email protected]> Co-authored-by: Teppo Kurki <[email protected]>
- Loading branch information
1 parent
589b3f8
commit 9ceb7d7
Showing
8 changed files
with
344 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
flow-tests/test-react-router/src/main/java/com/vaadin/flow/BackNavFirstView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright 2000-2024 Vaadin Ltd. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
|
||
package com.vaadin.flow; | ||
|
||
import com.vaadin.flow.component.html.Div; | ||
import com.vaadin.flow.component.html.NativeButton; | ||
import com.vaadin.flow.router.Route; | ||
|
||
@Route("com.vaadin.flow.BackNavFirstView") | ||
public class BackNavFirstView extends Div { | ||
|
||
public BackNavFirstView() { | ||
add(new NativeButton("Navigate", event -> getUI() | ||
.ifPresent(ui -> ui.navigate(BackNavSecondView.class)))); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
flow-tests/test-react-router/src/main/java/com/vaadin/flow/BackNavSecondView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright 2000-2024 Vaadin Ltd. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
|
||
package com.vaadin.flow; | ||
|
||
import com.vaadin.flow.component.UI; | ||
import com.vaadin.flow.component.html.Div; | ||
import com.vaadin.flow.component.html.Span; | ||
import com.vaadin.flow.router.AfterNavigationEvent; | ||
import com.vaadin.flow.router.AfterNavigationObserver; | ||
import com.vaadin.flow.router.Route; | ||
|
||
@Route("com.vaadin.flow.BackNavSecondView") | ||
public class BackNavSecondView extends Div implements AfterNavigationObserver { | ||
|
||
public static final String CALLS = "calls"; | ||
private int count = 0; | ||
Span text = new Span("Second view: " + count); | ||
|
||
public BackNavSecondView() { | ||
text.setId(CALLS); | ||
add(text); | ||
} | ||
|
||
@Override | ||
public void afterNavigation(AfterNavigationEvent event) { | ||
count++; | ||
text.setText("Second view: " + count); | ||
UI.getCurrent().getPage().getHistory().replaceState(null, | ||
"com.vaadin.flow.BackNavSecondView?param"); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
flow-tests/test-react-router/src/main/java/com/vaadin/flow/ForwardTargetView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
...ests/test-react-router/src/main/java/com/vaadin/flow/ForwardTargetWithParametersView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
flow-tests/test-react-router/src/main/java/com/vaadin/flow/ForwardingToParametersView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
flow-tests/test-react-router/src/main/java/com/vaadin/flow/ForwardingView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.