Skip to content

[IndexTable] Sticky column problem with long content #4012

@lhoffbeck

Description

@lhoffbeck

Issue summary

When the sticky first column of the index table contains content wider than the table container, the table can't be scrolled far enough to see additional content.

108216505-8f1e5300-7100-11eb-99f6-d0c7568d5f6e

Expected behavior

User should be able to see all the table content after scrolling.

Actual behavior

User can't see all content of indextable when the first column has long content.

Reduced test case

Playground.tsx

import React from 'react';

import {Card, IndexTable, Page, TextStyle, useIndexResourceState} from '../src';

export function Playground() {
  return (
    <Page title="Playground">
      <SimpleIndexTableExample />
      {/* Add the code you want to test in here */}
    </Page>
  );
}

function SimpleIndexTableExample() {
  const customers = [
    {
      id: '3411',
      url: 'customers/341',
      name: 'asdfasdfadsfadsasdfasdfadsfadsasdfasdfadsfadsasdfasdfadsfadsasdfasdfadsfadsasdfasdfadsfadsasdfasdfadsfadsasdfasdfadsfadsasdfasdfadsfadsasdfasdfadsfadsasdfasdfadsfadsasdfasdfadsfadsasdfasdfadsfadsasdfasdfadsfadsasdfasdfadsfadsasdfasdfadsfads',
      location: 'Decatur, USA',
      orders: 20,
      amountSpent: '$2,400',
    },
    {
      id: '2561',
      url: 'customers/256',
      name: 'asdfasdfadsfads asdfasdfadsfads asdfasdfadsfads asdfasdfadsfads asdfasdfadsfads asdfasdfadsfads asdfasdfadsfads asdfasdfadsfads',
      location: 'Los Angeles, USA',
      orders: 30,
      amountSpent: '$140',
    },
  ];
  const resourceName = {
    singular: 'customer',
    plural: 'customers',
  };

  const {
    selectedResources,
    allResourcesSelected,
    handleSelectionChange,
  } = useIndexResourceState(customers);

  const rowMarkup = customers.map(
    ({id, name, location, orders, amountSpent}, index) => (
      <IndexTable.Row
        id={id}
        key={id}
        selected={selectedResources.includes(id)}
        position={index}
      >
        <IndexTable.Cell>
          <TextStyle variation="strong">{name}</TextStyle>
        </IndexTable.Cell>
        <IndexTable.Cell>{location}</IndexTable.Cell>
        <IndexTable.Cell>{orders}</IndexTable.Cell>
        <IndexTable.Cell>{amountSpent}</IndexTable.Cell>
      </IndexTable.Row>
    ),
  );

  return (
    <Card>
      <IndexTable
        resourceName={resourceName}
        itemCount={customers.length}
        selectedItemsCount={
          allResourcesSelected ? 'All' : selectedResources.length
        }
        onSelectionChange={handleSelectionChange}
        headings={[
          {title: 'Name'},
          {title: 'Location'},
          {title: 'Order count'},
          {title: 'Amount spent'},
        ]}
      >
        {rowMarkup}
      </IndexTable>
    </Card>
  );
}

Specifications

  System:
    OS: macOS 10.15.7
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 158.93 MB / 32.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 10.15.0 - ~/.nvm/versions/node/v10.15.0/bin/node
    Yarn: 1.13.0 - ~/.dev/yarn/v1.13.0/bin/yarn
    npm: 6.4.1 - ~/.nvm/versions/node/v10.15.0/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Browsers:
    Chrome: 88.0.4324.182
    Chrome Canary: 90.0.4424.0
    Firefox: 85.0.2
    Firefox Developer Edition: 85.0
    Safari: 13.1.3
  npmPackages:
    react: ^16.9.0 => 16.9.0 
    react-dom: ^16.9.0 => 16.9.0 

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething is broken and not working as intended in the system.untriaged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions