Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The selection box is misplaced when I scroll the table (only safari) #900

Closed
RomanKwok opened this issue Sep 6, 2019 · 4 comments
Closed
Labels
needs verification For issues that can't be reproduced or are otherwise unclear

Comments

@RomanKwok
Copy link

Screenshot 2019-09-07 at 12 06 41 AM

@gabrielliwerant
Copy link
Collaborator

Hello @RomanKwok. Can you create a codesandbox example that demonstrates the issue? I have a PC, so I cannot download the latest safai for testing. There are some options I can use for testing, but the free trials are limited in capabilities, so having an example ready to go that I can load in a browser will be a big help.

@gabrielliwerant gabrielliwerant added the needs verification For issues that can't be reproduced or are otherwise unclear label Sep 6, 2019
@RomanKwok
Copy link
Author

Hi, @gabrielliwerant. Thanks for your reply.
I created a sample with codesandbox, please check it.
thanks.

https://codesandbox.io/embed/polished-sun-2dj96?fontsize=14
Screenshot 2019-09-07 at 1 05 02 PM

@patorjk
Copy link
Collaborator

patorjk commented Sep 9, 2019

I can confirm this. It is also present in iOS devices on Chrome (and probably other browsers). If you alter @RomanKwok's example use to use "scrollMaxHeight", you'll see the problem on the iPhone in Chrome. If you create a table with 10+ rows, you'll also see the issue happens for the table headers when you scroll right.

The issue is due to "position: sticky" in TableSelectCell.js and TableHeadCell.js. It's unclear to me if the bug is in Safari and iOS Chrome's implementation of sticky, or the desktop browser's implementation of sticky. Whatever the case, it can be fixed: simply don't stick for the positions you don't want to stick. What this means is removing "top:0px" from the rule for checkboxes that aren't the header, and removing "left:0px" for table header labels. Ex:

TableSelectCell.js

    fixedHeader: {
      position: 'sticky',
      top: '0px',
      left: '0px',
      zIndex: 100,
    },
    fixedLeft: {
      position: 'sticky',
      left: '0px',
      zIndex: 100,
    },

...

  const cellClass = classNames({
    [classes.root]: true,
    [classes.fixedHeader]: fixedHeader && isHeaderCell,
    [classes.fixedLeft]: fixedHeader && !isHeaderCell,
    [classes.headerCell]: isHeaderCell,
  });

TableHeadCell.js:

    fixedHeader: {
      position: 'sticky',
      top: '0px',
      //left: '0px',
      zIndex: 100,
      backgroundColor: theme.palette.background.paper,
    },

There's also a related bug here: if you have 10+ columns and you scroll right, you'll see the column text overlaps the checkboxes on the left. This can be fixed by setting the background color of TableSelectCells to theme.palette.background.paper and adjusting the CSS rules in TableBodyRow.js:

    root: {
      '&.MuiTableRow-root.Mui-selected': {
        '& td': {
          backgroundColor: '#ededed',
        }        
      }
    },
    hover: {
      '&:hover': {
        '& td': {
          backgroundColor: '#ededed',
        }
      }
    },

@patorjk
Copy link
Collaborator

patorjk commented Jun 9, 2020

Issue fixed in version 3.0.0 of the table.

@patorjk patorjk closed this as completed Jun 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs verification For issues that can't be reproduced or are otherwise unclear
Projects
None yet
3 participants