question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Browser back should restore body like it was before

See original GitHub issue

Description 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:open
  • Created a year ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
knoobiecommented, Aug 2, 2022

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 😉

0reactions
taeficommented, Aug 2, 2022

@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).

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found