question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Sort] Cannot add clickable icon inside of the sort header in IE

See original GitHub issue

Bug, feature request, or proposal:

Adding a clickable icon is to a mat-sort-header is not possible in IE11. IE11 will not listen to click events inside of <button>. Changing to <div> might work.

What is the expected behavior?

Adding click events to header should work in IE11.

What is the current behavior?

Click events are completely ignored by IE11 browser.

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

Adding additional clickable icons in the Table header.

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

Angular 4.4.4 Material 2.0.0.beta.12 Typescript 2.4.2 IE11 Wandows

Is there anything else we should know?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:6
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

22reactions
ozsivanovcommented, Sep 21, 2018

As a workaround, you can move the mat-sort-header directive to an element inside of the mat-header-cell:

So if you have something like:

<mat-header-cell *matHeaderCellDef mat-sort-header arrowPosition="before">
  <span>Column Title</span>
  <button>Click Me!</button>
</mat-header-cell>

Moving the directive into the span will work (with some minor styling tweaks):

<mat-header-cell *matHeaderCellDef>
  <span mat-sort-header arrowPosition="before">Column Title</span>
  <button>Click Me!</button>
</mat-header-cell>
8reactions
gangsthubcommented, Oct 19, 2018

Also happening in Firefox 😦

Default <ng-content> inside button is limiting the user’s possibilities:

https://github.com/angular/material2/blob/63f713f846a1b2c5a69c4342f0816085a341457f/src/lib/sort/sort-header.html#L4-L10

Current spec for buttons in HTML5’s living standard says:

Content model: Phrasing content, but there must be no interactive content descendant.

There could be a prop like interactuableContent in the mat-sort, that would make the content render inside a div instead of a button (being backwards compatible).

Thanks, guys.

EDIT: @ozsivanov has suggested a better approach that could work as a workaround later in this thread 👇

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mat-table Sorting Demo not Working - Stack Overflow
this is fine, in the header text is clickable and the icon is also there but still sorting is not working. Can I...
Read more >
Sort header - Angular Material
To add sorting behavior and styling to a set of table headers, add the <mat-sort-header> component to each header and provide an id...
Read more >
Add interactive sort to a table or matrix in paginated reports
In a table or matrix in report design view, right-click the text box in the column header for the group to which you...
Read more >
jQuery plugin: Tablesorter 2.0 - Angel Pet Sitters
Property Type Default Link cancelSelection Boolean true cssAsc String "" cssChildRow String "tablesorter‑childRow" 1 2
Read more >
D12337 Give the file dialogs a "Sort by" menu button on the toolbar
FWIW, here's the macOS sort icon, as shown in the open dialog: ... the text right in the toolbar, move it as a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found