Search code examples
internet-explorer-11material-uiangular6

Material-UI drop-down menu causing error in IE11


Unfortunately we have to support IE11.

The following is a snippet of Angular from our app:

<nav class="navbar-menu" fxFill>
    <span class="fill-it"></span>
    <span class="nav-user-wrap" fxFlexAlign="right">
        <button class="nav-user" mat-button [matMenuTriggerFor]="usrmenu">{{ userManager.currentDealer?.name }} <mat-icon class="icon-avatar">person</mat-icon><mat-icon class="icon-arrwdwn">keyboard_arrow_down</mat-icon></button>
        <mat-menu #usrmenu="matMenu" class="userdd mmdd" xPosition="after" yPosition="below" [overlapTrigger]="false">
            <span mat-menu-item [disabled]="true" [disableRipple]="true">{{ userManager.firstName }} {{ userManager.lastName }}</span>
            <mat-divider style="border-color: rgba(255,255,255,0.8); margin: 0 16px;"></mat-divider>

            <span mat-menu-item *ngIf="!userManager.isDealerGroupUser" (click)="openSelectDealerGroupDialog()">{{ userManager.dealerGroup?.name }}</span>
            <mat-divider *ngIf="!userManager.isDealerGroupUser" style="border-color: rgba(255,255,255,0.8); margin: 0 16px;"></mat-divider>

            <button *ngFor="let dealer of userManager.dealers" (click)="userManager.setCurrentDealer(dealer.id)" mat-menu-item>{{ dealer.name }} <span *ngIf="dealer.id === userManager.defaultDealer?.id">(Default)</span></button>

            <mat-divider style="border-color: rgba(255,255,255,0.8); margin: 0 16px;"></mat-divider>
            <!-- <button mat-menu-item>My Account</button>
            <button mat-menu-item>Settings</button> -->
            <button mat-menu-item (click)="logOut()">Logout</button>
        </mat-menu>
    </span>
</nav>

Pretty standard drop-down menu, but in IE11 clicking the button gives the following exception:

Unable to get property 'opacity' of undefined or null reference

I'm pulling my hair out trying to work out why. Does IE11 do some kind of pseudo-script thing in the background to set the CSS or something? No idea.

All help appreciated!


Solution

  • This error is a result of IE11 lacking the Web Animation API, to fix this You have to import the right polyfill as documented in Angular Docs.

    import 'web-animations-js'