Skip to content

Route beforeLeave handler is called twice when using stackPages #3975

@blikblum

Description

@blikblum

Describe the bug

When exiting a nested page, beforeLeave route handler is called twice, the second time with params different from the actual transition

This occurs when using stackPages: true

To Reproduce

Steps to reproduce the behavior:

  1. Go to https://codepen.io/blikblum/pen/BampNNq
  2. Click on Person link
  3. Click on Fact link
  4. Click on About link
  5. Open console to view beforeLeave logging
  6. Click on back button
    beforeLeave is called twice
    first time with from.path === '/about/' and to.path === '/fact/'
    second time is called with from.path === '/fact/' and to.path === '/person/'

Expected behavior

beforeLeave is called once with from.path === '/about/' and to.path === '/fact/'

Actual Behavior

beforeLeave is called twice
first time with from.path === '/about/' and to.path === '/fact/'
second time is called with from.path === '/fact/' and to.path === '/person/'

Screenshots

[..]

Additional context

The same behavior is observed in v5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions