Skip to content

[navigation and routing] Routing sample Dialog broken on web plaform, Back button does not close #2018

Open
@nolandg

Description

@nolandg

The Routing and Navigation sample has a dialog accessible from the Settings screen. The Cancel/OK buttons use Navigator.pop() to close the dialog and that works

onPressed: () => Navigator.pop(context, 'Cancel'),

But when the dialog is open and the web browser's back button is pressed, the dialog stays open and the page behind it navigates back. This is wrong.

I'm confident that this is would be highly unexpected UX for any real app--the back button should have the same effect as poping to maintain a consistent UX.

This is a serious problem my team has been unable to solve. We've tried all of the following and none of them seem to trigger for the browser's back button:

  • WillPopScope
  • BackButtonListener
  • backButtonDispatcher.didPopRoute()
  • window.onBeforeUnload

If we can't listen for the back button and warn the user about unsaved data loss and block the navigation, this is a serious limitation of the platform. How are people solving this? Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions