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(cdk/drag-drop): Improper positioning of drag preview since it uses native popover (v17.3.6 and above) #29809

Closed
1 task done
stanley-skyline opened this issue Oct 1, 2024 · 2 comments · Fixed by #29813
Assignees
Labels
area: cdk/drag-drop P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@stanley-skyline
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

17.3.5

Description

A specific combination of an already existing CSS declaration on a cdkDrag element causes the position of the drag preview element to be incorrect because the resulting CSS is no longer identical to how it was prior to using the native popoper (so prior to version 17.3.6).

The exact cause is the addition of user agent styling that was not applied before, namely: inset: 0px; (using Chrome)
In addition to the properties top and left (which are always set to 0 anyway), bottom and right are now also set to 0 by the UA styles being applied now.

This CSS rule should be extended I think (with inset: unset;).

Reproduction

StackBlitz link: https://stackblitz.com/edit/jn6uje?file=src%2Fexample%2Fcdk-drag-drop-sorting-example.css
Steps to reproduce:

  1. Drag "Item 1" (observe that the element is not at the position of the pointer, but quite a bit down)
  2. See how align-self: center; affects the position of the drag preview.

Expected Behavior

Using align-self: center on the cdkDrag element (.example-box) should not affect the position of the drag preview. The position should be exactly the same as when this CSS declaration is not used. In other words, there should be no difference in the final result compared to when cdk/drag-drop did not use popoper under the hood for the preview.

Actual Behavior

The element is centered vertically between top and bottom (if you do not consider the transform).

The combination of CSS below results in this particular issue (only properties included that really lead to this particular behavior):

element.style {
    position: fixed !important;
    top: 0px;
}

.example-box {
    align-self: center;
}

/* user agent stylesheet */
[popover] { 
    inset: 0px;
}

Environment

  • Angular: 19.0.0-next.2
  • CDK/Material: 19.0.0-next.2
  • Browser(s): Chrome
  • Operating System (e.g. Windows, macOS, Ubuntu): Windows 11
@stanley-skyline stanley-skyline added the needs triage This issue needs to be triaged by the team label Oct 1, 2024
@sOnU1002
Copy link

sOnU1002 commented Oct 1, 2024

i would like to work on this issue please assign me task

@crisbeto crisbeto self-assigned this Oct 2, 2024
@crisbeto crisbeto added P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent area: cdk/drag-drop and removed needs triage This issue needs to be triaged by the team labels Oct 2, 2024
crisbeto added a commit to crisbeto/material2 that referenced this issue Oct 2, 2024
Fixes that the combination of setting `align-self: center` and the user agent styling of `inset: 0` on popovers was breaking the positioning of the preview.

Fixes angular#29809.
crisbeto added a commit that referenced this issue Oct 2, 2024
Fixes that the combination of setting `align-self: center` and the user agent styling of `inset: 0` on popovers was breaking the positioning of the preview.

Fixes #29809.

(cherry picked from commit 5be8905)
@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 Nov 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: cdk/drag-drop 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.

3 participants