Skip to content

Commit

Permalink
fix(cdk/drag-drop): reset user agent color on preview popover
Browse files Browse the repository at this point in the history
After #28945 the preview is inserted into a `popover` element which has a user agent styling of `color: canvastext`. These changes reset it to `inherit` to match the old behavior.

Fixes #28974.
  • Loading branch information
crisbeto committed May 1, 2024
1 parent dde3793 commit a3b3211
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/cdk/drag-drop/directives/drag.spec.ts
Expand Up @@ -2515,6 +2515,15 @@ describe('CdkDrag', () => {
expect(previewContainer)
.withContext('Expected preview container to be in the DOM')
.toBeTruthy();
expect(previewContainer.style.color)
.withContext('Expected preview container to reset user agent color')
.toBe('inherit');
expect(previewContainer.style.margin)
.withContext('Expected preview container to reset user agent margin')
.toMatch(zeroPxRegex);
expect(previewContainer.style.padding)
.withContext('Expected preview container to reset user agent padding')
.toMatch(zeroPxRegex);
expect(preview.textContent!.trim())
.withContext('Expected preview content to match element')
.toContain('One');
Expand Down
1 change: 1 addition & 0 deletions src/cdk/drag-drop/preview-ref.ts
Expand Up @@ -121,6 +121,7 @@ export class PreviewRef {
'pointer-events': 'none',
'margin': '0',
'padding': '0',
'color': 'inherit',
});
toggleNativeDragInteractions(wrapper, false);

Expand Down

0 comments on commit a3b3211

Please sign in to comment.