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(cdkDropList/mat-tab-nav-bar): Wrong container for cdkPlaceHolder/cdkDrag after drag/hover from other list #29140

Closed
1 task
gkrzysztofbury opened this issue May 29, 2024 · 1 comment · Fixed by #29283
Assignees
Labels
area: cdk/drag-drop feature This issue represents a new feature or feature request rather than a bug or bug fix P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@gkrzysztofbury
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

No response

Description

The issue occurs when a button from the second nav-bar is dragged very slowly into the first one from the right side.

This happens because the mat-tab-nav-bar is not a single <div>, but consists of several layers:

<div mat-tab-nav-bar cdkDropList>
  <button class="mat-mdc-tab-header-pagination-chevron"></button>
  <div class="mat-mdc-tab-link-container">
    <div class="mat-mdc-tab-list">
      <div class="mat-mdc-tab-links">
        <!-- content, "Tab 1", etc -->
      </div>
    </div>
  </div>
  <button class="mat-mdc-tab-header-pagination-chevron"></button>
  <!-- "Tab 5" lands here in the video --> 
</div>

When the dragged button enters another nav-bar, this function is called: single-axis-sort-strategy.ts#L175. Since it does not find newPositionReference, the base cdkDropList element is used as the parent of the placeholder: single-axis-sort-strategy.ts#L213.

Reproduction

Video: YouTube
StackBlitz: Example

Expected Behavior

Dragged button lands along with others

Actual Behavior

Dragged button lands in wrong container

Environment

  • Angular:
  • CDK/Material:
  • Browser(s):
  • Operating System (e.g. Windows, macOS, Ubuntu): all
@gkrzysztofbury gkrzysztofbury added the needs triage This issue needs to be triaged by the team label May 29, 2024
@crisbeto
Copy link
Member

Duplicate of #29124.

@crisbeto crisbeto self-assigned this Jun 19, 2024
@crisbeto crisbeto added feature This issue represents a new feature or feature request rather than a bug or bug fix 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 Jun 19, 2024
@crisbeto crisbeto reopened this Jun 19, 2024
crisbeto added a commit to crisbeto/material2 that referenced this issue Jun 19, 2024
…t container

Adds the new `cdkDropListElementContainer` input that allows users to specify a different element that should be considered the root of the drop list. This is useful in the cases where the user might not have full control over the DOM between the drop list and the items, like when making a tab list draggable.

Fixes angular#29140.
DBowen33 pushed a commit to DBowen33/components that referenced this issue Jul 3, 2024
…t container (angular#29283)

Adds the new `cdkDropListElementContainer` input that allows users to specify a different element that should be considered the root of the drop list. This is useful in the cases where the user might not have full control over the DOM between the drop list and the items, like when making a tab list draggable.

Fixes angular#29140.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: cdk/drag-drop feature This issue represents a new feature or feature request rather than a bug or bug fix 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.

2 participants