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

bug(matTooltip): Tooltip not displaying when mat-icon is nested within mat-button #28888

Closed
1 task done
andrii-3sdev opened this issue Apr 16, 2024 · 4 comments · Fixed by #29291
Closed
1 task done
Assignees
Labels
area: material/button P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@andrii-3sdev
Copy link

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

In Angular Material version 17.3.x, tooltips fail to display when a mat-icon element is nested within any type of Material button, such as mat-button, mat-raised-button, mat-flat-button, etc. Despite applying the matTooltip directive to the mat-icon, the tooltip does not appear when hovering over the icon within the button. This behaviour is inconsistent with previous versions of Angular Material, where tooltips functioned correctly in similar scenarios. Unfortunately, I don't know from which version it appeared

Code Example:

Tooltip not displaying within a mat-button

<button mat-button>
  <mat-icon matTooltip="Home page">home</mat-icon>
</button>

Removing the button wrapper allows the tooltip to display as expected.

<button>
  <mat-icon matTooltip="Home page">home</mat-icon>
</button>

Reproduction

StackBlitz link: https://stackblitz.com/edit/components-issue-ucd6z2?file=src%2Fapp%2Fexample-component.html
Steps to reproduce:

  1. Hover an icon on button
  2. Hover an icon on a material button

Expected Behavior

Tooltip

Actual Behavior

No tooltip

Environment

  • Angular: 17.3.x
  • CDK/Material: 17.3.x
  • Browser(s): all
  • Operating System (e.g. Windows, macOS, Ubuntu): Windows, macOS
@andrii-3sdev andrii-3sdev added the needs triage This issue needs to be triaged by the team label Apr 16, 2024
@Azbesciak
Copy link

Azbesciak commented Apr 17, 2024

Confirm, the issue is caused by spans inside with .mat-mdc-focus-indicator and .mat-mdc-button-touch-target.
If it has display: none tooltips work.

@crisbeto
Copy link
Member

The fix here would be to stack the button's content on top of the touch target.

@crisbeto crisbeto added P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent area: material/button and removed needs triage This issue needs to be triaged by the team labels Apr 18, 2024
@gasfab999
Copy link

For now one can fix the matTooltip as well by setting the style z-index: 1 on the mat-icon element.
Then at least the icon is placed above the touch target element and the tooltip appears on hover. I'm not 100% sure if this may cause side effects on touch devices.

@crisbeto crisbeto self-assigned this Jun 20, 2024
crisbeto added a commit to crisbeto/material2 that referenced this issue Jun 20, 2024
Some time ago we started stacking the button's text on top of the ripple and touch target for accessibility reasons, but we didn't apply the same to icons.

Fixes angular#28888.
crisbeto added a commit that referenced this issue Jun 25, 2024
Some time ago we started stacking the button's text on top of the ripple and touch target for accessibility reasons, but we didn't apply the same to icons.

Fixes #28888.

(cherry picked from commit f67ffa5)
DBowen33 pushed a commit to DBowen33/components that referenced this issue Jul 3, 2024
Some time ago we started stacking the button's text on top of the ripple and touch target for accessibility reasons, but we didn't apply the same to icons.

Fixes angular#28888.
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jul 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: material/button P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants