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

New element added to ic-data-table when sorting a truncated column #2819

Open
GCHQ-Developer-741 opened this issue Nov 22, 2024 · 1 comment
Labels
data-table component The generic component, includes both the web component and the React component type: bug 🐛 Something isn't working

Comments

@GCHQ-Developer-741
Copy link
Contributor

Summary of the bug

When sorting a table that contains a cell with a truncated value (only occurs when using truncationPattern="tooltip"), the cell content shifts to the right, although it still truncates correctly and displays the tooltip.

The reason for this is down to the fact that when this happens, a new ic-tooltip element is being added into the cell (with no height so it is not visible), which shifts the visible content over to accommodate it. See screenshots below for visual example. Interestingly, every time a new column is sorted, a new tooltip element is added.

🪜 How to reproduce

  1. Copy code example below
  2. Click on any sort button
  3. See the error

📸 Screenshots or code

const COLS = [
  { key: "name", title: "Name", dataType: "string" },
  { key: "age", title: "Age", dataType: "number" },
  { key: "department", title: "Department", dataType: "string" },
  { key: "employeeNumber", title: "Employee Number", dataType: "number" },
  { key: "jobTitle", title: "Job Title", dataType: "string" },
];

// Example data
const DATA = [
  {
    name: "Mark",
    age: 36,
    department: "Accounts & Finance",
    employeeNumber: 1,
    jobTitle: "Senior Financial Operations and Reporting Analyst",
  },
  {
    name: "Anne",
    age: 32,
    department: "Engineering",
    employeeNumber: 2,
    jobTitle:
      "Senior Software Engineer, Site Reliability Engineering (Microsoft Azure)",
  },
  {
    name: "Tim Rayes",
    age: 41,
    department: "Sales and Marketing",
    employeeNumber: 3,
    jobTitle:
      "Regional Sales and Marketing Strategy Director (Europe, the Middle East, and Africa)",
  },
];

<IcDataTable
  caption="Truncating tooltip"
  columns={COLS}
  data={DATA}
  truncationPattern="tooltip"
  sortable
/>

Before sorting (see only one tooltip in devtools)

Screenshot 2024-11-22 at 15 42 53

After sorting (now two tooltips, visible one pushed to the side)

Screenshot 2024-11-22 at 15 43 12

Sorting a second column (three tooltips, content pushed even further)

Screenshot 2024-11-22 at 15 43 40

🧐 Expected behaviour

I suggest that if cell content is already wrapped in a tooltip, then do not create an additional element.

@GCHQ-Developer-741 GCHQ-Developer-741 added type: bug 🐛 Something isn't working data-table component The generic component, includes both the web component and the React component labels Nov 22, 2024
@GCHQ-Developer-741
Copy link
Contributor Author

Doesn't require any tests as there is already one that caught this bug. Has been commented out to get dark mode through, but should be added back once this is fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data-table component The generic component, includes both the web component and the React component type: bug 🐛 Something isn't working
Projects
Status: No status
Development

No branches or pull requests

1 participant