Let a filter rule be dragged into place
Twenty-five rules and two buttons that move one place at a time meant a rule pushed to the wrong end cost ten clicks to bring back. It can now be dragged. A grip on the left of each card arms the drag, so the switch, the name and the buttons still take a plain click, and the up and down buttons stay for the keyboard. The card being dragged fades; the one under the pointer draws a line on the edge the rule would land on, top half or bottom. The guard against dropping a rule onto itself reads a ref rather than state: dragstart and the first dragover can arrive in the same frame, and a stale read there drew a drop line on the card being dragged. Found by driving the real thing in a browser, and covered by a test that fires the two events back to back.
This commit is contained in:
@@ -605,6 +605,12 @@ img { max-width: 100%; }
|
||||
.swatch.active { border-color: var(--fg); }
|
||||
.rule-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; background: var(--bg-elev); }
|
||||
.rule-card.disabled { opacity: .6; }
|
||||
.rule-card.dragging { opacity: .5; }
|
||||
/* The line shows which side of this card the dragged rule would land on. */
|
||||
.rule-card.drop-above { box-shadow: inset 0 3px 0 0 var(--accent); }
|
||||
.rule-card.drop-below { box-shadow: inset 0 -3px 0 0 var(--accent); }
|
||||
.rule-card .drag-handle { display: flex; align-items: center; padding: 2px; margin-left: -4px; color: var(--fg-faint); cursor: grab; touch-action: none; }
|
||||
.rule-card .drag-handle:active { cursor: grabbing; }
|
||||
.rule-row { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 8px; align-items: center; margin-bottom: 8px; }
|
||||
.rule-row.actions { grid-template-columns: 1fr 2fr auto; }
|
||||
/* A header typed by hand needs a box of its own, alongside the comparator. */
|
||||
|
||||
Reference in New Issue
Block a user