Skip to content

[Table] Throw error if MatSortModule is not imported while using "MatSort/matSort" #11079

@WizardPC

Description

@WizardPC

Bug, feature request, or proposal

Proposal

What is the expected behavior?

Using @ViewChild(MatSort) sort: MatSort; and <mat-table [dataSource]="dataSource" matSort> without import { MatSortModule } from '@angular/material'; will throw an error like some other material component (if i remember it's something like "you need to import xxxx....")

What is the current behavior?

Nothing, the sorting arrows are just not displayed (and sorting doesn't work)

What are the steps to reproduce?

Just remove the MatSortModule :
https://stackblitz.com/angular/voqnaoexppp?file=main.ts

What is the use-case or motivation for changing an existing behavior?

I lost many hours on this... i take some code from my stackblitz to my main project and continue developping, but after a moment i see sorting doesn't work anymore without errors in the console... I search, scratch my head, and finally reverse my code to the beginning but still not working !

Finally i found solution online, import MatSortModule... so depressing :(

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

Latest

Is there anything else we should know?

I know it's my fault, but without error it's difficult to find this.

Metadata

Metadata

Assignees

Labels

P5The team acknowledges the request but does not plan to address it, it remains open for discussionarea: material/sortdocsThis issue is related to documentationfeatureThis issue represents a new feature or feature request rather than a bug or bug fix

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions