Skip to content

navigation confirmation in edit mode

Tim Eder requested to merge hackathon-navigation-confirmation-in-edit-mode into develop

added a warning dialog component that stops a user from accidentally navigating away with unsaved changes.

it requires the beforeRouteLeave hook on the page where it is used:

  // eslint-disable-next-line @typescript-eslint/no-unused-vars
  beforeRouteLeave (to: RawLocation, from: RawLocation, next: any) {
    if (this.deviceHasBeenEdited && !this.hasSaved) {
      if (this.to && this.to) {
        next()
      } else {
        this.to = to
        this.showNavigationWarning = true
      }
    } else {
      return next()
    }
  }

as well as a check for changes in the form data and a route object

Merge request reports