Skip to content

Mat Sorting on Mat Table calls re-render multiple times #21667

Closed
@AshotAleqs

Description

@AshotAleqs

Reproduction

I am not sure this is a bug, but I think it is wrong. I know the mat table change detection strategy is onPush,
and it will re-render when the datasource reference will be changed, but when you are using mat Sorting on that table, it will re-render the table when you will hover that sortable header, it comes from components/src/material/sort/sort-header.ts file there are 2 events added. to the host

 '(mouseenter)': '_setIndicatorHintVisible(true)',
 '(mouseleave)': '_setIndicatorHintVisible(false)',

info from package.json

  "dependencies": {
    "@angular/animations": "~11.0.5",
    "@angular/cdk": "^11.0.3",
    "@angular/common": "~11.0.5",
    "@angular/compiler": "~11.0.5",
    "@angular/core": "~11.0.5",
    "@angular/forms": "~11.0.5",
    "@angular/material": "^11.0.3",
  },

Here is the simple reproduction example: https://stackblitz.com/edit/stackoverflow-table-example?file=src/app/table-basic-example.ts

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs triageThis issue needs to be triaged by the team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions