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

First column of Index Table does not have border when selectable=false #9639

Open
schiller-manuel opened this issue Jul 6, 2023 · 6 comments

Comments

@schiller-manuel
Copy link

Issue summary

I noticed that for the first column of an Index Table no border is shown when selectable=false

Expected behavior

All columns should have border.

Actual behavior

First column does not have border:

Screenshot 2023-07-06 at 20 04 03

Steps to reproduce the problem

Use an Index Table with prop selectable={false}

I noticed that there is a white background for this column:

Screenshot 2023-07-06 at 20 11 20

When disabling the white background,
Screenshot 2023-07-06 at 20 12 24

almost all borders are correctly displayed, only the header row is missing its bottom border:

Screenshot 2023-07-06 at 20 12 41

Reduced test case

This is directly visible in the Index Table documentation example "without checkboxes" on https://polaris.shopify.com/components/tables/index-table

The example code is located at: https://codesandbox.io/s/yubt4v?module=App.tsx&file=/App.tsx

Specifications

  • Are you using the React components? (Y/N): Y
  • Polaris version number: latest, i.e. 11.4.3
  • Browser: Firefox
  • Device: MacBook
  • Operating System: macOS 12.5
Copy link
Contributor

github-actions bot commented Jan 5, 2024

Hi! We noticed there hasn’t been activity on this issue in a while. After 30 days, it will close automatically.

If it’s still relevant, or you have updates, comment and let us know. And don’t worry, you can always re-open later if needed.

@schiller-manuel
Copy link
Author

still relevant

Copy link
Contributor

github-actions bot commented Jul 6, 2024

Hi! We noticed there hasn’t been activity on this issue in a while. After 30 days, it will close automatically.

If it’s still relevant, or you have updates, comment and let us know. And don’t worry, you can always re-open later if needed.

@schiller-manuel
Copy link
Author

seems to be fixed

@ngbrown
Copy link

ngbrown commented Mar 8, 2025

This is still an issue with the current version of Polaris 13.9.2. It's happening in my app on Polaris and, even though it's not immediately visible, in the documentation. If you resize the width of the documentation preview or open the CodeSandbox (https://codesandbox.io/p/sandbox/lv94sl), it can be illustrated.

It seems to have something to do with when the table is scrolling or not, the cells move down slightly, covering the border.

Preview.-.nodebox.-.CodeSandbox.-.Google.Chrome.2025-03-08.13-05-21.mp4

This up/down jank when the scrollbar appears is also present without selectable={false}, but the background color isn't applied until the table actually starts scrolling.

I think the fix would be for this

.TableCell-first,
.TableCell-first + .TableCell,
.TableHeading-first,
.TableHeading-second {
visibility: visible;
background-color: var(--p-color-bg-surface);
}

and this:

&.Table-unselectable {
/* stylelint-disable-next-line selector-max-class, selector-max-specificity -- generated by polaris-migrator DO NOT COPY */
.TableHeading-second,
.TableCell:first-child {
visibility: visible;
}
}

to be merged (or at least add background-color to the Table--unselectable definition).

And this removed (remove background-color from the .Polaris-IndexTable__Table--unselectable.Polaris-IndexTable__Table--sticky .Polaris-IndexTable__TableCell:first-child definition):

background-color: var(--p-color-bg-surface);

As proof, I've overwritten the styles with the following CSS to get it working in my app:

.Polaris-IndexTable__Table--unselectable.Polaris-IndexTable__Table--sticky
  .Polaris-IndexTable__TableCell:first-child {
  background-color: transparent;
}

.Polaris-IndexTable__Table--scrolling.Polaris-IndexTable__Table--unselectable
  .Polaris-IndexTable__TableHeading--second,
.Polaris-IndexTable__StickyTable--scrolling.Polaris-IndexTable__Table--unselectable
  .Polaris-IndexTable__TableHeading--second,
.Polaris-IndexTable__Table--scrolling.Polaris-IndexTable__Table--unselectable
  .Polaris-IndexTable__TableCell:first-child,
.Polaris-IndexTable__StickyTable--scrolling.Polaris-IndexTable__Table--unselectable
  .Polaris-IndexTable__TableCell:first-child {
  background-color: var(--p-color-bg-surface);
}

See CodeSandbox with the CSS applied: https://codesandbox.io/p/sandbox/interesting-saha-vlr3px

@dwchau
Copy link

dwchau commented Mar 10, 2025

i have a trick to fix it, with a code example like @ngbrown , i'll update it:

In rowMarkup, when you loop through the rows of the table, you just need to insert one "fake" column at the beginning. For example, if you have 6 columns, insert 1 column at the start, making a total of 7. For that first column, set display: none. Well, the problem is that this works for me.

in rowMarkup inside <IndexTable>{rowMarkup}</IndexTable>:

  const rowMarkup = orders.map(
    (
      { id, order, date, customer, total, paymentStatus, fulfillmentStatus },
      index
    ) => (
      <IndexTable.Row id={id} key={id} position={index}>
        {/* ========================= INSERT FAKE CELL HERE */}
          <IndexTable.Cell />

        <IndexTable.Cell>
          <Text variant="bodyMd" fontWeight="bold" as="span">
            {order}
          </Text>
        </IndexTable.Cell>
        <IndexTable.Cell>{date}</IndexTable.Cell>
        <IndexTable.Cell>{customer}</IndexTable.Cell>
        <IndexTable.Cell>
          <Text as="span" alignment="end" numeric>
            {total}
          </Text>
        </IndexTable.Cell>
        <IndexTable.Cell>{paymentStatus}</IndexTable.Cell>
        <IndexTable.Cell>{fulfillmentStatus}</IndexTable.Cell>
      </IndexTable.Row>
    )
  );

and in index.module.css

:global(.Polaris-IndexTable__Table--unselectable.Polaris-IndexTable__Table--sticky .Polaris-IndexTable__TableCell:first-child) {
  display: none;
}

:global(.Polaris-IndexTable__Table--unselectable.Polaris-IndexTable__Table--sticky .Polaris-IndexTable__TableCell:nth-child(2)) {
  background-color: unset;
}

:global(.Polaris-IndexTable__Table--scrolling.Polaris-IndexTable__Table--sticky.Polaris-IndexTable__Table--unselectable .Polaris-IndexTable__TableCell:nth-child(2)) {
  left: 0;
  position: sticky;
  z-index: var(--pc-index-table-sticky-cell);
  background-color: var(--p-color-bg-surface);
  filter: drop-shadow(0.0625rem 0 0 var(--p-color-border-secondary));
}

Code for test: https://codesandbox.io/p/devbox/hopeful-bird-pv23hz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants