Browser back should restore body like it was before
See original GitHub issueDescription of the bug
When a dialog is shown (added to the body and set opened true), it does not get cleaned up when using browser back. Same goes with vcf tooltip. This leads to unexpected behaviour, if for example the dialog is confirmed afterwards.
Expected behavior
The dialog should be closed and removed from the body, even if it has no close or cancel action, as browser back is a “hard action”
Minimal reproducible example
Use the following two routes:
@Route("view")
public class View extends Div {
public View() {
add(new Button("go to dialog", e -> UI.getCurrent().navigate("dialog")));
}
}
@Route("dialog")
public class DialogView extends Div {
public DialogView() {
add(new Button("open dialog", e -> {
Dialog dialog = new Dialog(new Span("Do you really want to send?"));
dialog.getFooter().add(new Button("confirm", ev -> {
Span result = new Span("An error occured in the backend");
result.getStyle().set("color", "red");
add(result);
dialog.setOpened(false);
}), new Button("cancel", ev -> dialog.setOpened(false)));
dialog.setOpened(true);
}));
}
}
- Go to “view” and click “go to dialog”. Click “open dialog”. A dialog opens. Click “confirm” and the backend error is displayed.
- Do that again, but before hitting confirm on the dialog, click browser back button. The dialog is still there. Now try to confirm the dialog. The error is not shown this time.
Versions
- Vaadin / Flow version: 23.1.2
- Java version: 11
Issue Analytics
- State:
- Created a year ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Browser back button restores empty fields - Stack Overflow
IE will retain form contents on a back button click automatically, as long as: you haven't broken cacheing with a no-cache pragma or...
Read more >History back() Method - W3Schools
The history.back() method loads the previous URL (page) in the history list. The history.back() method only works if a previous ...
Read more >How to Reset Google Chrome and Restore Your Settings
When you reset Chrome, you won't lose any bookmarks or passwords, but all your other settings will revert to their original conditions.
Read more >Why daylight saving time is worse for your body than standard ...
Because you already would have been awake for hours before the sun rose, it would be less capable of “pulling” your clock back...
Read more >How to Restore Body Composition After Pregnancy
Good news, you can regain back your body composition. ... were in good shape before pregnancy, physical changes to your body like additional ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I would argue it’s intended, because a dialog can be shown on multiple views / routes and the developer can choose what they want with the tools available. But I’m not working for vaadin, just wanted to give you a quick workaround 😉
@timbo86 I can say this is not a bug since it works as intended. However, there can be some arguments about the default behavior of the dialog while navigating via menu or by manually entering the URL in the address bar or using the back and forward button in different circumstances e.g. being modal or not. Also, I can confirm this is working the same in V14 (dialog remains open when navigating with back and forward buttons).