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

Nested tables do not properly expand #3854

Closed
nyurik opened this issue Aug 3, 2020 · 0 comments · Fixed by #3855
Closed

Nested tables do not properly expand #3854

nyurik opened this issue Aug 3, 2020 · 0 comments · Fixed by #3855

Comments

@nyurik
Copy link
Contributor

nyurik commented Aug 3, 2020

Simple repo: https://codesandbox.io/s/modest-mclaren-ku8v3 -- expand the first row, and expand the first row of the first subrow. Instead of properly showing 3 headers one after another, the top portion of the table is hidden.

vokoscreen-2020-08-03-10-46-45

copy of the sample code from above
import React, {useState, useMemo} from "react";
import { render } from "react-dom";
import "./styles.scss";
import "./index.css";

import {
  EuiInMemoryTable,
  EuiButtonIcon,
} from '@elastic/eui';

let tableCounter = 0;

export const Table = () => {
  const [itemIdToExpandedRowMap, setItemIdToExpandedRowMap] = useState({});

  const toggleDetails = item => {
    const itemIdToExpandedRowMapValues = { ...itemIdToExpandedRowMap };
    if (itemIdToExpandedRowMapValues[item.id]) {
      delete itemIdToExpandedRowMapValues[item.id];
    } else {
      itemIdToExpandedRowMapValues[item.id] = (<Table />);
    }
    setItemIdToExpandedRowMap(itemIdToExpandedRowMapValues);
  };

  const columns = [
    {
      field: 'row',
      name: 'Row Name',
    },
    {
      name: 'Click to Expand',
      isExpander: true,
      render: item => (
        <EuiButtonIcon
          onClick={() => toggleDetails(item)}
          aria-label={itemIdToExpandedRowMap[item.id] ? 'Collapse' : 'Expand'}
          iconType={itemIdToExpandedRowMap[item.id] ? 'arrowUp' : 'arrowDown'}
        />
      ),
    },
  ];

  const items = useMemo(() => {
    function createItems(count) {
      let index = 0;
      tableCounter++;
      return Array.apply(0, Array(count)).map(() => ({
        id: `${++index}`,
        row: `row ${index} in table ${tableCounter}`,
      }));
    }
    return createItems(20);
  }, []);

  return (
      <EuiInMemoryTable
        items={items}
        itemId="id"
        itemIdToExpandedRowMap={itemIdToExpandedRowMap}
        isExpandable={true}
        columns={columns}
      />
  );
};


render(<Table />, document.getElementById("app"));
nyurik added a commit that referenced this issue Aug 3, 2020
In some cases max-height of a sub-row needs to be more than 1000px. I tried setting `max-height: max-content`, but the expansion animation was not smooth, so instead added a two step animation -- to 1000px at 90%, and to `max-content` at 100%.

Fixes #3854
nyurik added a commit that referenced this issue Aug 18, 2020
In some cases max-height of a sub-row needs to be more than 1000px. I tried setting `max-height: max-content`, but the expansion animation was not smooth, so instead added a two step animation -- to 1000px at 90%, and to `max-content` at 100%.

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

Successfully merging a pull request may close this issue.

1 participant