components icon indicating copy to clipboard operation
components copied to clipboard

Mat Tab Group & Ivy: selectedIndex not a property of HTMLElement

Open james-schwartzkopf opened this issue 7 years ago • 15 comments

Reproduction

https://github.com/james-schwartzkopf/ng8-issues/tree/mat-tab-group-ivy-selected-index

Steps to reproduce:

  1. yarn
  2. yarn run build

Expected Behavior

Should compile cleanly and tabs should work.

Actual Behavior

Error:

ERROR in src/app/app.component.html(2,16): Property 'selectedIndex' does not exist on type 'HTMLElement'.

Notes

May be related to #16750

The error doesn't occur using @angular/material 8.1.4 or with Ivy disabled.

I'm guessing this is due to the change to _MatTabGroupBase, maybe it needs an @Directive? Not 100% sure how inheritance works in Ivy. https://github.com/angular/angular/pull/31379

Environment

  • Angular: 8.2.6
  • CDK/Material: 8.2.0

james-schwartzkopf avatar Sep 13 '19 22:09 james-schwartzkopf

I am facing same issue after enabling IVY.

<mat-tab-group class="col-lg-12" [selectedIndex]="activeAppraiserTabIndex">

The above worked perfectly before enabling IVY

After enabling I get this error

Property 'selectedIndex' does not exist on type 'HTMLElement'.

Not sure if its related with IVY

enstenr-zz avatar Sep 16 '19 06:09 enstenr-zz

I confirm that. I am facing same issue with ivy too.

Because of that I can't do any url on tab -> I can't use index of tab in url and use "selectedIndex" for dynamically change tabs :(

UPD. I found that this bug can be circumvented if we remove mat-tab-group node from template with *ngIf directive. mat-tab-group with selectedIndex and *ngIf directive works fine for me.

ottodranik avatar Sep 17 '19 11:09 ottodranik

Same issue in Angular 9.

GenuineRex avatar Sep 19 '19 15:09 GenuineRex

This also happens with <nav mat-tab-nav-bar> <a mat-tab-link [active]="..."> It's actually the only error I get now enabling Ivy in 8.2. Can workaround the error by disabling typecheck in tsconfig.app.json

"angularCompilerOptions": {
    "enableIvy": true,
    "fullTemplateTypeCheck": false,
    "ivyTemplateTypeCheck": false,
    "allowEmptyCodegenFiles": true
  },

gdjennings avatar Sep 22 '19 08:09 gdjennings

Any news on this issue?

obautista avatar Mar 07 '20 22:03 obautista

Apparently now it works though my code editor says: "Property selectedIndex is not provided by any applicable directives nor by mat-tab-group element"

matteoulissi avatar Apr 15 '20 16:04 matteoulissi

Same here for any input or output of mat-tab-group: selectedTabChange selectedIndex

TheParad0X avatar Apr 17 '20 08:04 TheParad0X

I'm not sure if my error is the same but after I migrated my app from Angular 8.2.3 to 9, only in the Editor (IntelliJIdea), I got:

<mat-tab-group [(selectedIndex)]="..."

==> "Can't bind to [(selectedIndex)] since it is not provided by any applicable directives" on the "selectedIndex"

                          (selectedTabChange)="...">

==> "Event selectedTabChange is not emitted by any applicable directives nor by mat-tab-group element"

But this happens only in WebStorm (the editor) because if i run the application with "ng serve" it works fine!

Any idea about it?

Sorry if i'm OT

UPDATE:

In my case the problem is the Editor. So new RC solves the problem.

robo3945 avatar May 28 '20 08:05 robo3945

I ran the original reproduction that was given and created an Ivy stackblitz with the given code, in both cases it compiled fine, so I think this was fixed.

mmalerba avatar May 28 '20 20:05 mmalerba

Error still happening here on webstorm ... It compiles fine anyway

mariusvn avatar Jun 02 '20 14:06 mariusvn

Same here.

TheParad0X avatar Jun 02 '20 14:06 TheParad0X

I wonder if something in the webstorm toolchain is on an old version that has the issue. I don't think there's anything the Angular Components team can do since its already compiling fine at HEAD

mmalerba avatar Jun 02 '20 19:06 mmalerba

I personally did the test with the Webstorm 2020.1.2 RC and it solves my problem.

robo3945 avatar Jun 03 '20 04:06 robo3945

Webstorm 2020.1.2 solves the problem for me too

TheParad0X avatar Jun 05 '20 13:06 TheParad0X

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.