88 </span >
99 </div >
1010
11- <div class =" min-h-0 flex-1 overflow-y-auto" >
11+ <div class =" min-h-0 flex-1 overflow-y-auto" @dragleave = " onListDragLeave " >
1212 <div
1313 v-for =" node in rows"
1414 :key =" node.id"
@@ -177,7 +177,7 @@ function isRowSelected(id: string): boolean {
177177
178178function rowClass(selected : boolean , extra ? : string ): string {
179179 return cn (
180- ' group flex cursor-pointer items-center gap-2 border-border-default px-2 py-1.5 select-none' ,
180+ ' group relative flex cursor-pointer items-center gap-2 border-border-default px-2 py-1.5 select-none' ,
181181 ' hover:bg-secondary-background-hover' ,
182182 selected && ' bg-secondary-background-selected' ,
183183 extra
@@ -208,20 +208,19 @@ function endDrag(): void {
208208
209209function dropHintClass(id : string ): string {
210210 const hint = dropHint .value
211- if (hint ?.id !== id ) return ' relative'
212- return cn (
213- ' relative' ,
214- hint .pos === ' above'
215- ? " before:absolute before:inset-x-0 before:top-0 before:h-0.5 before:bg-base-foreground before:content-['']"
216- : " after:absolute after:inset-x-0 after:bottom-0 after:h-0.5 after:bg-base-foreground after:content-['']"
217- )
211+ if (hint ?.id !== id ) return ' '
212+ return hint .pos === ' above'
213+ ? " before:absolute before:inset-x-0 before:top-0 before:h-0.5 before:bg-base-foreground before:content-['']"
214+ : " after:absolute after:inset-x-0 after:bottom-0 after:h-0.5 after:bg-base-foreground after:content-['']"
218215}
219216
220217function onRowDragStart(id : string , e : DragEvent ): void {
221218 dragId .value = id
222219 if (e .dataTransfer ) {
223220 e .dataTransfer .effectAllowed = ' move'
224- e .dataTransfer .setData (' text/plain' , id )
221+ // Firefox refuses to start the drag without data; empty keeps text
222+ // inputs from receiving the layer id on a stray drop.
223+ e .dataTransfer .setData (' text/plain' , ' ' )
225224 }
226225}
227226
@@ -237,21 +236,28 @@ function onRowDragOver(id: string, e: DragEvent): void {
237236}
238237
239238function onRowDrop(id : string , e : DragEvent ): void {
240- e .preventDefault ()
241239 const dragged = dragId .value
242240 const hint = dropHint .value
243- if (dragged && hint ?.id === id ) {
244- const toIndex = reorderDropIndex (
245- imageLayers .value .map ((n ) => n .id ),
246- id ,
247- hint .pos ,
248- backgroundLayer .value ? 1 : 0
249- )
250- if (toIndex !== null ) session .moveLayerTo (dragged , toIndex )
241+ if (! dragged || hint ?.id !== id ) {
242+ endDrag ()
243+ return
251244 }
245+ e .preventDefault ()
246+ const toIndex = reorderDropIndex (
247+ imageLayers .value .map ((n ) => n .id ),
248+ id ,
249+ hint .pos ,
250+ backgroundLayer .value ? 1 : 0
251+ )
252+ if (toIndex !== null ) session .moveLayerTo (dragged , toIndex )
252253 endDrag ()
253254}
254255
256+ function onListDragLeave(e : DragEvent ): void {
257+ const container = e .currentTarget as HTMLElement
258+ if (! container .contains (e .relatedTarget as Node | null )) dropHint .value = null
259+ }
260+
255261function onRowClick(id : string , e : MouseEvent ): void {
256262 if (e .ctrlKey || e .metaKey || e .shiftKey ) {
257263 const current = selectedNodeIds .value
0 commit comments