question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug(drag-drop): moved item doesn't retain inherited styles

See original GitHub issue

Bug, feature request, or proposal:

Bug

What is the expected behavior?

When dragging around an item, all styles (included the inherited ones) shall be retained to keep the look&feel consistent

What is the current behavior?

Inherithed styles are not retained

What are the steps to reproduce?

  1. Create a list of elements suitable for D&D
  2. Add mat-typography class on the cdk-drop container
  3. Drag one item of the list and notice that it doesn’t retain Roboto font

What is the use-case or motivation for changing an existing behavior?

Consistency

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

Angular 6.1.8 Material 6.4.7

Is there anything else we should know?

As a workaround it’s possible to add to items a class with all needed styles which would have been inherited from the container.

Being moved to root level (aka out of it’s normal containers and CSS rules flow) for the duration of the dragging event, the item should have all currently applied inherited CSS rules copied to avoid inconsistent look&feel

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:19
  • Comments:23 (6 by maintainers)

github_iconTop GitHub Comments

23reactions
matt328commented, Nov 29, 2018

This is especially cumbersome when working with mat-list-items that need to be children of a mat-list in order for their styling to be applied correctly.

8reactions
bhumin3icommented, Jun 11, 2019

same issue :

<mat-nav-list class="p-0 " perfectScrollbar>
           <mat-list dense cdkDropList [cdkDropListData]="sharedService.sharedUserProfiles"
             [cdkDropListConnectedTo]="getCategoryIds()" class="top-margin">
             <mat-divider></mat-divider>
             <mat-list-item class="cust-display-list" mat-line
               *ngFor="let profile of sharedService.sharedUserProfiles, let i = index" cdkDrag>
               <img matListAvatar class="fix-avatar-height" src="/assets/user.jpg" alt="...">
               <h3 matLine>{{profile.info.fullname}} </h3>
               <p matLine>
                 <span> {{profile.info.title}}</span>
               </p>
               <button mat-icon-button>
                 <mat-icon>drag_indicator</mat-icon>
               </button>
               <mat-divider></mat-divider>
             </mat-list-item>
           </mat-list>
         </mat-nav-list>

drag_style

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular material drag-drop design not working properly
This may not be desireable in some cases, because the preview won't retain its inherited styles.
Read more >
Cdk Drag Drop Does Not Correctly Change The Position Of ...
Bug feature request or proposal: Bug. What is the expected behavior? When dragging around an item all styles included the inherited ones shall...
Read more >
Drag and Drop | Angular Material
Doesn't retain inherited styles. Preview is inserted inside the parent of the item that is being dragged. Preview inherits the same styles as...
Read more >
Angular: How to Implement Drag and Drop in a Material tree
Together, Drag and Drop and Material Tree don't work out of the box because you have to manipulate the data based on the...
Read more >
overscroll-behavior - CSS: Cascading Style Sheets | MDN
If you have overscroll-behavior: contain; selected, the outer container will not scroll unless you move your cursor out of the inner ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found