Skip to content

bug(material/tooltip): tooltip inside sidenav hides after text update #27782

Open
@amanosacrous

Description

@amanosacrous

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 the tooltip component overflows a parent sidenav and its text content is updated dynamically, it hides.

We have debugged the code, and this happens because the sidenav component extends the cdk-scrollable.

The piece of code that calls the tooltip hide function is the following:

strategy.positionChanges.pipe(takeUntil(this._destroyed)).subscribe(change => {
this._updateCurrentPositionClass(change.connectionPair);
if (this._tooltipInstance) {
if (change.scrollableViewProperties.isOverlayClipped && this._tooltipInstance.isVisible()) {
// After position changes occur and the overlay is clipped by
// a parent scrollable then close the tooltip.
this._ngZone.run(() => this.hide(0));
}
}
});

Reproduction

Stackblitz url:
https://stackblitz.com/edit/stackblitz-starters-wbd1hh?file=src%2Ftooltip-sidenav%2Ftooltip-sidenav.component.html

As you can see on the stackBlitz example, we have two tooltips:

  • The tooltip inside the sidenav, which overflows the sidenav component. That if we update the tooltip text, the tooltip disappears. (BUG)
  • On the other hand, we have the tooltip inside the mat-sidenav-content which works properly, and it doesn't hide after updating it. (WORKS WELL because doesn't overflow the parent)

Expected Behavior

The tooltip inside the sidenav should not hide when the text is updated.

Actual Behavior

The tooltip placed inside the sidnav that overflows is hidden suddenly when the text is updated.

Environment

  • Angular: v16.2.4
  • CDK/Material: v16.2.3
  • Browser(s): Google chrome Versión 116.0.5845.187, Firefox 117.0
  • Operating System (e.g. Windows, macOS, Ubuntu): Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    P4A relatively minor issue that is not relevant to core functionsarea: material/tooltiphelp wantedThe team would appreciate a PR from the community to address this issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions