Skip to content

bug: Menu freezes if closed and disabled while animation is in progress #20092

Description

@damirarh

Bug Report

Ionic version:

[x] 4.x

Current behavior:

If you attempt to close and disable the menu while the opening animation is still in progress, the menu will freeze in place. The application will need to be reloaded to resume normal operation. The following error message is emitted in the console:

vendor.js:104532 Error: ASSERT: can not be animating
    at assert (vendor.js:106591)
    at Menu.updateState (38.js:410)
    at Menu.disabledChanged (38.js:82)
    at vendor.js:105830
    at Array.forEach (<anonymous>)
    at setValue (vendor.js:105827)
    at HTMLElement.set [as disabled] (vendor.js:105868)
    at Object.enable (vendor.js:106778)

Expected behavior:

The menu should close and become disabled even if these calls are issued while the opening animation is in progress. The opening animation should either be interrupted or continue till the end before the menu is closed.

Steps to reproduce:

I encountered the issue with a menu item that triggered navigation to another page. In the ionViewWillLeave method of the current page I had the following code:

await this.menuCtrl.close();
await this.menuCtrl.enable(false);

The key to reproducing the issue is to click on the menu item quickly after clicking the menu toggle button to open the menu. The menu animation must still be in progress at that point.

The issue can also be reproduced if the two lines above are directly placed in the menu item handler. That's what I did in the sample application.

Related code:

https://github.com/damirarh/ionic-menu-freezing

Other information:

Ionic info:

Ionic:

   Ionic CLI                     : 5.2.8 (C:\Users\damir\AppData\Roaming\npm\node_modules\ionic)
   Ionic Framework               : @ionic/angular 4.11.7
   @angular-devkit/build-angular : 0.801.3
   @angular-devkit/schematics    : 8.1.3
   @angular/cli                  : 8.1.3
   @ionic/angular-toolkit        : 2.1.1

Utility:

   cordova-res : not installed
   native-run  : 0.2.7

System:

   NodeJS : v10.16.0 (C:\Program Files\nodejs\node.exe)
   npm    : 6.9.0
   OS     : Windows 10

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