Skip to content

feat(tooltip): add overflow tooltip directive - #2353

Draft
spike-rabbit wants to merge 1 commit into
mainfrom
feat/tooltip-overflow
Draft

feat(tooltip): add overflow tooltip directive#2353
spike-rabbit wants to merge 1 commit into
mainfrom
feat/tooltip-overflow

Conversation

@spike-rabbit

@spike-rabbit spike-rabbit commented Jul 15, 2026

Copy link
Copy Markdown
Member

Usage

<span siTooltipOverflow>
  I am very long and maybe I am truncated.
  But my tooltip is only added when I am actually truncated.
</span>

Problem to solve

We have many places where text is eventually truncated if there is not enough space.
Since we do not know upfront if the text is truncated, we need to apply a tooltip conditionally.
Currently, we simply do not apply any tooltips in those cases.

The first place where I plan to use this directive is the breadcrumb. There we currently violate a11y by attaching a menu in case text is truncated. Also the truncation itself is implemented in a poor way.

Approach

Whenever the target element is hovered / focused we check if the text is truncated and update the tooltip content
based on the innerText.
Since we check the truncation and innerText always immediately before showing, we don't need any listener for changes.


Documentation.
Examples.
Dashboards Demo.
Playwright report.

Coverage Reports:

Code Coverage

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the 'SiTooltipOverflowDirective', which automatically displays a tooltip containing the host element's text when it overflows and is truncated. It includes unit tests and updates the example application to showcase the new directive. Feedback was provided regarding the execution of 'updateTooltip()' outside the Angular zone, which prevents automatic change detection for the tooltip's event handlers. It is recommended to run the state updates and tooltip creation/destruction inside the Angular zone using 'NgZone.run()'.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread projects/element-ng/tooltip/si-tooltip-overflow.directive.ts Outdated
@spike-rabbit

Copy link
Copy Markdown
Member Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the SiTooltipOverflowDirective to automatically display a tooltip when host element text overflows, along with supporting updates to SiTooltipService to accept a canShow callback. However, refactoring SiTooltipDirective to use this callback for isDisabled removes the property from the effect dependency tracking, causing a regression where dynamically disabling a visible tooltip will not immediately hide or destroy it.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread projects/element-ng/tooltip/si-tooltip.directive.ts Outdated
@spike-rabbit

Copy link
Copy Markdown
Member Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the SiTooltipOverflowDirective to automatically display tooltips for truncated text, refactors SiTooltipDirective to instantiate tooltip references directly using a computed canShow signal, and updates SiTooltipService to support this conditional visibility. Feedback on the changes highlights a critical runtime error (NG0600) in SiTooltipOverflowDirective caused by updating a signal inside an effect's execution path. The reviewer recommends replacing the tooltipText signal with a direct getter function to resolve this issue and subsequently removing the unused signal import.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread projects/element-ng/tooltip/si-tooltip-overflow.directive.ts Outdated
Comment thread projects/element-ng/tooltip/si-tooltip-overflow.directive.ts Outdated
@spike-rabbit
spike-rabbit force-pushed the feat/tooltip-overflow branch 6 times, most recently from d81880d to 3a2ad8e Compare July 17, 2026 07:20
Add a directive that automatically renders a tooltip if the host text is truncated.
@spike-rabbit
spike-rabbit force-pushed the feat/tooltip-overflow branch from 3a2ad8e to 941bb05 Compare July 17, 2026 07:36
@spike-rabbit spike-rabbit added the core-team-discussion Topics that should be discussed in the core team meeting label Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core-team-discussion Topics that should be discussed in the core team meeting

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant