Skip to content

Commit 88b2ea2

Browse files
committed
Improve styling of handle-less BorderBox rows
Tags the dragula mirror with `data-dragging="mirror"` and the source row with `data-dragging="source"`, then adds Primer overrides so the mirror reads as a distinct floating card (background, border, shadow) while the source row renders as a faded "ghost" at reduced opacity. Also suppresses `.Box-row--hover-*` colors during a drag to stop hover flicker as the mirror passes over the list.
1 parent 62105d9 commit 88b2ea2

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

frontend/src/global_styles/primer/_overrides.sass

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,12 @@ ul.SegmentedControl,
156156
.ActionListItem-label[class^="__hl_"], .ActionListItem-label[class*=" __hl_"]
157157
color: var(--control-fgColor-disabled) !important
158158

159+
// hide hover when dragging with legacy Dragula implementation
160+
.Box-row--hover-gray,
161+
.Box-row--hover-blue
162+
body[data-dragging="active"] &
163+
background-color: unset
164+
159165
.Box-row--focus-gray
160166
&:focus-visible
161167
background-color: var(--bgColor-muted)
@@ -170,6 +176,23 @@ ul.SegmentedControl,
170176
.Box-row--draggable:not(.Box-row--clickable)
171177
cursor: grab
172178

179+
// `:is(.Box-row--clickable)` bumps selector specificity so these rules win
180+
// over Dragula's `.gu-*` transit styles; without it the mirror and source
181+
// rows render transparent mid-drag. Revisit once #74172 / #73729 replace the
182+
// legacy Dragula implementation.
183+
.Box-row:is(.Box-row--clickable)
184+
&[data-dragging="mirror"]
185+
background-color: var(--bgColor-default)
186+
border: var(--borderWidth-default) solid var(--borderColor-default)
187+
border-radius: var(--borderRadius-medium)
188+
box-shadow: var(--shadow-floating-medium)
189+
opacity: 1
190+
191+
&[data-dragging="source"]
192+
opacity: 0.4
193+
background-color: var(--bgColor-subtle)
194+
box-shadow: inset 0 0 0 var(--borderWidth-default) var(--borderColor-muted)
195+
173196
// Apply the mobile styles as soon as the banner itself is small
174197
// Styles are copied from the PVC repo
175198
.op-primer-flash

frontend/src/stimulus/controllers/dynamic/generic-drag-and-drop.controller.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,19 @@ export default class GenericDragAndDropController extends Controller {
132132
mirrorContainer: this.resolveMirrorContainer(),
133133
},
134134
)
135+
.on('cloned', (clone, _original, type) => {
136+
clone.setAttribute('data-dragging', type);
137+
})
135138
.on('drag', (el, source) => {
136139
this.dragOriginSource = source;
137140
this.dragOriginNextSibling = el.nextElementSibling;
138141

142+
el.setAttribute('data-dragging', 'source');
139143
document.body.setAttribute('data-dragging', 'active');
140144
this.ariaPressedTarget(el)?.setAttribute('aria-pressed', 'true');
141145
})
142146
.on('dragend', (el) => {
147+
el.removeAttribute('data-dragging');
143148
document.body.removeAttribute('data-dragging');
144149
this.ariaPressedTarget(el)?.setAttribute('aria-pressed', 'false');
145150
})

0 commit comments

Comments
 (0)