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.

[TableSortLabel] Remove sort icon when not active

See original GitHub issue

Table sort labels reserve space for the sort icon even when the column isn’t the active sort. This prevents layout changes when clicking on a column for sorting, but this also uses horizontal space. I think the icon should be hidden rather than of 0% opacity.

  • This is a v1.x issue.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior

When a table header is not active for sort, the arrow is hidden (with `display: ‘none’), i.e. it takes no horizontal space

Current Behavior

When a table header is not active for sort, the arrow is displayed, but with 0% opacity. If this actually hides the arrow, it also uses horizontal space.

Examples

Material Design doesn’t specify that the space for the arrow should be reserved. I understand that it helps for a nicer animation (by transitioning the opacity), but the effect on horizontal space it too high a price.

image

Context

Especially for number columns, where the header is often larger than the content, horizontal space is sparse. Imagine a table with many columns, each containing only numbers. the spacing between each column (due to the space reserved for the arrow if active) makes the table too large to fit in one screen without scrolling

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:4
  • Comments:10 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
oliviertassinaricommented, Aug 17, 2018

One more thought. We could add a property to enable this behavior. I think that it’s generic enough to be considered. What do you think about it?

0reactions
arjunaglcommented, Sep 6, 2018

Hello @fzaninotto I am new to material-ui and trying to contribute. I tried to pass in the custom style as you have mentioned by passing in a custom style

const styles = {
    icon: {
        display: 'none',
    },
    active: {
        '& $icon': {
            display: 'inline',
        },
    },
};

I am trying to do this in the examples and I’m using the EnhancedTable.js example. Maybe I’m trying it wrong, however what I’m trying to do is the following

                <TableSortLabel
                    active={orderBy === row.id}
                    style={styles}
                    direction={order}
                    onClick={this.createSortHandler(row.id)}
                  >

This does not work as expected since I’m passing in classes actually. When I try to pass in the same using classes also it does not work, since classes are expecting class names as strings. Since I’m new to this its very likely that I’m doing something wrong. Any help.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[TableSortLabel] Remove sort icon when not active #12561
When a table header is not active for sort, the arrow is displayed, but with 0% opacity. If this actually hides the arrow,...
Read more >
TableSortLabel API - Material UI - MUI
API reference docs for the React TableSortLabel component. Learn about the props, CSS, and other APIs of this ... Hide sort icon when...
Read more >
How to overwrites the ArrowDownwardIcon icon in React ...
What I am trying to do next is to overwrite the sort icon in header column which is ArrowDownwardIcon from the TableSortLabel source...
Read more >
How to hide the sort icon - Tableau Community
Do you want to hide the sort icon that appears next to dimension names? Try to convert the column dimensions to attributes -...
Read more >
React MUI TableSortLabel API - GeeksforGeeks
hideSortIcon: If true, it hides the sort icon. IconComponent: It is the icon of the TableSortLable. Syntax: Create the TableSortLabel component ...
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