Skip to content

bug(matTooltipDisabled): not working when boolean expression given is like "array.length" #31826

@alessandrospinelli

Description

@alessandrospinelli

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

When using matTooltip, passing an expression like "array.length" into [matTooltipDisabled] will be considered true even if array is empty, so the tooltip is always hidden.
Instead with the condition "array.length > 0" matTooltipDisabled works properly.
I don't know if this behavior used to work in a previous version but "array.length" is valid from ages as a boolean condition in angular (also in html)

Reproduction

StackBlitz link: https://stackblitz.com/edit/components-issue-starter-umfckoz3?file=src%2Fmain.html
Steps to reproduce:

  1. Hover the button
  2. See how no tooltip appears
  3. Try to update condition in "array.length > 0"
  4. See how now tooltip appears

Expected Behavior

When passing an expression as "array.length" matTooltipDisabled should disable the tooltip only when the array is not empty

Actual Behavior

When passing an expression as "array.length" matTooltipDisabled always disables tooltip

Environment

  • Angular: 18.2.8 or newer
  • CDK/Material: 18.2.8 or newer
  • Browser(s): Google Chrome
  • Operating System (e.g. Windows, macOS, Ubuntu): Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs triageThis issue needs to be triaged by the team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions