This repository has been archived by the owner on Sep 5, 2024. It is now read-only.
panel: mdPanelPosition.relativeTo.addPanelPosition does not work reliably/docs unclear #11849
Labels
needs: investigation
The cause of this issue is not well understood and needs to be investigated by the team or community
P4: minor
Minor issues. May not be fixed without community contributions.
type: bug
Milestone
Bug
While working on debugging mdPanel-related issues, I ran into an issue with panel size/positioning.
CodePen and steps to reproduce the issue:
CodePen Demo which demonstrates the issue: https://codepen.io/oliversalzburg/pen/ExaqaRb
Detailed Reproduction Steps:
What is the expected behavior?
Everything works as intended. Dialog opens at the desired position.
What is the current behavior?
In certain scenarios, the panel will open at an invalid location.
From my observations, in certain scenarios, mdPanel will attempt to calculate the position for the panel while the panel is still set to be hidden (via
_md-panel-hidden
). In those cases, getBoundingClientRect will return a rect with all 0. This negatively impacts the calculation whenever the size of the dialog must be taken into account.https://github.com/angular/material/blob/master/src/components/panel/panel.js#L3117
The demo in the documentation actually sets a min-height for the dialog, which seems useless, until you realize it is the counter-measure against this behavior.
IMHO the correct solution would be to not rely on the bounding box calculations of invisible elements and instead show them before retrieving their bounds. The current approach is unreliable. However, if you hide a dialog (to later reuse it), you can not update the animation, because the panel is hidden and has a 0-rect bounding box. So the calculation is always wrong while the panel is in the hidden state and there is no way around that.
We currently believe this to also be the root cause for tooltips sometimes appearing off-screen and flying into position. For mdPanelAnimations, the bounding rect is also pulled for the openFrom argument. This can also potentially result in 0-rects and the tooltip will fly in from the origin.
Is there anything else we should know? Stack Traces, Screenshots, etc.
I'm still working through the specifics of this behavior and will add more details as they come up.
The text was updated successfully, but these errors were encountered: