mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-09-21 03:01:27 -03:00
feat(frontend): one grip reorder affordance for tags and trigger words
Model tags could already be reordered by dragging a chip, but the only hint was a `cursor: grab` on `.metadata-item` — a hover-only, mouse-only signal that also leaked into the bulk add-tags modal, where the chips are not sortable at all. Trigger words could not be reordered, and their order matters: "Copy Trigger Words" and the insert-into-node action join the array as-is to build a prompt. Both editors now share one vocabulary: a `⠿` grip that appears whenever the list has something to order, plus `Alt + arrow` keyboard moves with an aria-live announcement. Whether the chip body is draggable is a property of the item rather than of the feature: - tags have no click action of their own, so the whole chip stays draggable (`handleSelector: null`), with a 5px threshold so a click on the grip only focuses it - trigger words keep click-to-edit on the body, so a drag starts from the grip only - the grip is the element that opts out of touch scrolling (`touch-action: none`), so touch users drag by the grip in both editors - reordering is offered only while editing: trigger words reveal the grip from `.edit-mode`, tags from the edit container, which stays hidden outside edit mode The drag engine moves out of ModelTags.js into shared/pointerSort.js, which now marks sortable containers with `pointer-sort-enabled` so only lists that really sort show the grab cursor. Labels, the sortable flag, the keyboard handler and the live region live in shared/reorderSupport.js, and both editors render the same three `common.reorder.*` keys (translations follow in the next commit). Two inherited engine bugs are fixed on the way: the drop position was only settled when an animation frame was still pending, so a fast drag (or one that started by crossing the threshold) fell back into its original slot; and the guard that stops a drop from triggering the chip's own click handler was removed on a timer, swallowing unrelated clicks until the next task.
This commit is contained in:
@@ -92,41 +92,126 @@
|
||||
border-radius: var(--border-radius-xs);
|
||||
padding: 4px 8px;
|
||||
position: relative;
|
||||
cursor: grab;
|
||||
transition: transform 0.18s ease;
|
||||
}
|
||||
|
||||
.metadata-item:active {
|
||||
/* --- Shared chip reordering (tags + trigger words) ------------------------ */
|
||||
/* Chips in a list that is actually sortable advertise the grab gesture only
|
||||
then, so lists that cannot be reordered never lie about it. */
|
||||
|
||||
.metadata-items.pointer-sort-enabled .metadata-item {
|
||||
cursor: grab;
|
||||
}
|
||||
|
||||
.metadata-items.pointer-sort-enabled .metadata-item:active {
|
||||
cursor: grabbing;
|
||||
}
|
||||
|
||||
.metadata-item-dragging {
|
||||
/* Grip handle: always in the DOM, revealed when the list is sortable */
|
||||
.reorder-handle {
|
||||
display: none;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-shrink: 0;
|
||||
padding: 0;
|
||||
margin-left: -2px;
|
||||
border: none;
|
||||
background: transparent;
|
||||
color: var(--text-color);
|
||||
opacity: 0.4;
|
||||
font-size: 0.8em;
|
||||
line-height: 1;
|
||||
cursor: grab;
|
||||
/* Keep a touch drag on the handle from scrolling the surrounding panel */
|
||||
touch-action: none;
|
||||
transition: opacity 0.2s ease, color 0.2s ease;
|
||||
}
|
||||
|
||||
.has-sortable-words .reorder-handle {
|
||||
display: inline-flex;
|
||||
}
|
||||
|
||||
/* Tag chips have no flex gap (unlike trigger word tags), so the grip needs its
|
||||
own spacing before the tag text */
|
||||
.metadata-item .reorder-handle {
|
||||
margin-right: 4px;
|
||||
}
|
||||
|
||||
.reorder-handle:hover,
|
||||
.reorder-handle:focus-visible {
|
||||
opacity: 0.9;
|
||||
color: var(--lora-accent);
|
||||
}
|
||||
|
||||
.reorder-handle:focus-visible {
|
||||
outline: 2px solid var(--lora-accent);
|
||||
outline-offset: 1px;
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
.reorder-handle:active {
|
||||
cursor: grabbing;
|
||||
}
|
||||
|
||||
/* Hint shown in the edit controls row while reordering is available */
|
||||
.reorder-hint {
|
||||
display: none;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
margin-right: auto;
|
||||
font-size: 0.75em;
|
||||
color: var(--text-color);
|
||||
opacity: 0.6;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.has-sortable-words .reorder-hint {
|
||||
display: inline-flex;
|
||||
}
|
||||
|
||||
/* Snapped-to-grid transition for the remaining chips while dragging */
|
||||
.reorder-sorting > * {
|
||||
transition: transform 0.18s ease;
|
||||
}
|
||||
|
||||
/* The lifted chip that follows the pointer */
|
||||
.reorder-dragging {
|
||||
box-shadow: var(--shadow-dialog);
|
||||
cursor: grabbing;
|
||||
opacity: 0.95;
|
||||
transition: none;
|
||||
}
|
||||
|
||||
.metadata-item-placeholder {
|
||||
/* Drop target left behind by the lifted chip */
|
||||
.reorder-placeholder {
|
||||
border: 1px dashed var(--lora-accent);
|
||||
border-radius: var(--border-radius-xs);
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.metadata-items-sorting .metadata-item {
|
||||
transition: transform 0.18s ease;
|
||||
}
|
||||
|
||||
body.metadata-drag-active {
|
||||
body.reorder-drag-active {
|
||||
user-select: none;
|
||||
cursor: grabbing;
|
||||
}
|
||||
|
||||
body.metadata-drag-active * {
|
||||
body.reorder-drag-active * {
|
||||
cursor: grabbing !important;
|
||||
}
|
||||
|
||||
/* Screen-reader-only live region announcing reorder moves */
|
||||
.reorder-sr-only {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
padding: 0;
|
||||
margin: -1px;
|
||||
overflow: hidden;
|
||||
clip: rect(0, 0, 0, 0);
|
||||
white-space: nowrap;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
.metadata-item-content {
|
||||
color: var(--lora-accent) !important;
|
||||
font-size: 0.85em;
|
||||
|
||||
Reference in New Issue
Block a user