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

[ic-tree-item] Issues with other elements when truncating a tree item #2704

Closed
GCHQ-Developer-530 opened this issue Nov 1, 2024 · 3 comments
Assignees
Milestone

Comments

@GCHQ-Developer-530
Copy link
Contributor

GCHQ-Developer-530 commented Nov 1, 2024

Summary of the bug

When truncating the text label on a tree item, a tooltip should show.

If you add an icon to a tree item and a really long label, the tooltip shows but the icon is not centred.
If you add an extra long label to a parent tree item, the tooltip shows but the arrow dropdown disappears.
If you append the dropdown to the tree content before the tooltip e.g.

if (!tooltip) {
        const tooltipEl = document.createElement("ic-tooltip");
        tooltipEl.setAttribute("target", this.el.id);
        tooltipEl.setAttribute("label", typographyEl.textContent);
        tooltipEl.classList.add("ic-tooltip-overflow");
        tooltipEl.setAttribute("placement", "right");
        this.isParent && treeContent.appendChild(this.dropdownSpanEl); // ADD IN THIS LINE
        treeContent.appendChild(tooltipEl);
        tooltipEl.appendChild(typographyEl);
      }

Then the tooltip doesn't show as it's appended after the typography element in the DOM, with nothing inside it.

Separate to all of this behaviour, on our guidance site (v3 tree view branch) if you add a label that's too long, it doesn't truncate at all - just wraps.

📸 Screenshots or code

Guidance site behaviour:
Screenshot 2024-11-01 at 14 02 43

Current storybook behaviour:
Screenshot 2024-11-01 at 14 02 05

Storybook behaviour if you append the dropdown span:
Screenshot 2024-11-01 at 14 51 26

🧐 Expected behaviour

Truncation should work the same for any tree item no matter the other elements in the tree content.

Additional info

When fixing this issue, please check that it works in the design system tree view branch too by doing npm pack in the ui kit canary web components, react and docs folders and installing that locally on the tree view branch.

NOTE: This behaviour has been seen by amending the focus inset storybook example as it represents the guidance site, but the code suggests it's probably an issue when focusInset={false} as well.

@GCHQ-Developer-530
Copy link
Contributor Author

Also check if the icon needs the styles sorting when tree view header is truncated

@ad9242
Copy link
Contributor

ad9242 commented Nov 5, 2024

wrapping the truncateTreeItemLabel in componentDidLoad in a setTimeout seemed to help with truncation (it already does this for the treeview header label)

Image

however, the tooltip get's hidden behind the page header

@GCHQ-Developer-530 GCHQ-Developer-530 moved this from Ready for dev to In Refinement in Intelligence Community Design System Nov 5, 2024
@ad9242
Copy link
Contributor

ad9242 commented Jan 29, 2025

consider looking at #2938 at same time

@MI6-255 MI6-255 added this to the PI 11 V3 milestone Jan 29, 2025
@MI6-255 MI6-255 moved this from In Refinement to Ready for dev in Intelligence Community Design System Jan 30, 2025
@cd3859 cd3859 self-assigned this Feb 6, 2025
@cd3859 cd3859 moved this from Ready for dev to Dev In Progress in Intelligence Community Design System Feb 6, 2025
@cd3859 cd3859 moved this from Dev In Progress to In Review in Intelligence Community Design System Feb 12, 2025
@cd3859 cd3859 moved this from In Review to Done in Intelligence Community Design System Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment