Skip to content

When KeepAlive caches more items than its max prop allows, reactivated components may be erroneously marked as being unmounted #7355

@funkyvisions

Description

@funkyvisions

Vue version

3.2.45

Link to minimal reproduction

https://codesandbox.io/s/emit-issue-kezqfe

Steps to reproduce

Follow directions on reproduction site.

Click on "Create new page". Then click on the button in the blue box. Notice that it responds by showing "Clicked".
Do this 4 more times so that there are 5 pages (make sure you do the final click).
Now click on "Render page 4". Notice the click event does not get emitted all the way to the onClicked handler in Page.vue.
Click on "Render page 3" and the button works again.

What is expected?

emit should work

What is actually happening?

emit does not work

System Info

System:
    OS: macOS 12.6
    CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
    Memory: 20.04 MB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.13.1 - ~/.nvm/versions/node/v16.13.1/bin/node
    Yarn: 1.22.0 - /usr/local/bin/yarn
    npm: 8.1.2 - ~/.nvm/versions/node/v16.13.1/bin/npm
  Browsers:
    Chrome: 108.0.5359.98
    Edge: 108.0.1462.46
    Firefox: 106.0.3
    Safari: 16.2
  npmPackages:
    vue: 3.2.41 => 3.2.41

Any additional comments?

This was broken by this commit #5679. If I remove the 2 lines added

if (instance.isUnmounted)
    return;

then it works once again.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions