Closed
Description
Reproduction
When a mat-tooltip
is applied to an element within a cdk-virtual-scroll-viewport
that can be removed from the list bound to the *cdkVirtualFor
directive, the tooltip will not always be removed when it's corresponding anchor element is removed.
https://stackblitz.com/edit/tooltip-cdk-virtual-scroll-issue?file=src/app/example-component.html
Steps to reproduce:
Variant 1:
- Scroll to the bottom of the list.
- Hover the bottom-most button of the list to reveal its tooltip.
- Click the button to remove it.
- Notice that the tooltip does not disapear as it should, it moves to the upper left of the page. It will remain until the scrollbar of the list disappears, and then the list is reset. Resetting prior to the scrollbar disappearing will not remove the tooltip from the page. This is repeatable for all bottom-most button tooltips until the scroll bar disappears, at that point, you will start noticing the 2nd strange behavior (though it is also separately replicable).
Variant 2:
- Remove items from the list until the scroll bar disappears.
- Hover the bottom-most button of the list to reveal its tooltip.
- Click the button to remove it.
- Notice that the tooltip does not disapear as it should. It will remain until all items are removed from the list, the list is reset, the dialog is re-initialized (essentially the list being reset). This is repeatable for all bottom-most button tooltips until the last item in the list is removed.
Expected Behavior
The tooltip should be removed along with the element it is bound to.
Actual Behavior
The tooltip remains open when the element it is bound to is removed.
Environment
See linked StackBlitz dependencies, but:
- Angular: 12.0.3
- CDK/Material: 12.0.4
- Browser(s): Chrome, Firefox
- Operating System (e.g. Windows, macOS, Ubuntu): Windows