@innertia-solutions/innertia-nuxt 0.1.40 → 0.1.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -488,13 +488,23 @@ const onDrop = async (targetState) => {
488
488
 
489
489
  // Modo reorden (prop seteada): calcula vecinos y persiste posición.
490
490
  if (props.reorderEndpoint) {
491
- const colList = (columnRows.value[targetState] ?? []).filter(r => r.id !== id)
492
- const idx = dropIndex == null ? colList.length : Math.min(dropIndex, colList.length)
491
+ const rendered = columnRows.value[targetState] ?? []
492
+ const dragIdxInRendered = rendered.findIndex(r => r.id === id)
493
+ // dropIndex viene en espacio renderizado (incluye la tarjeta arrastrada en
494
+ // reorden misma-columna). Al filtrarla, los índices por debajo se corren -1.
495
+ let effectiveDrop = dropIndex
496
+ if (dragIdxInRendered >= 0 && dropIndex != null && dropIndex > dragIdxInRendered) {
497
+ effectiveDrop = dropIndex - 1
498
+ }
499
+
500
+ // No-op: soltar en el propio slot (misma columna, misma posición).
501
+ if (fromState === targetState && effectiveDrop === dragIdxInRendered) return
502
+
503
+ const colList = rendered.filter(r => r.id !== id)
504
+ const idx = effectiveDrop == null ? colList.length : Math.min(effectiveDrop, colList.length)
493
505
  const beforeId = idx > 0 ? colList[idx - 1].id : null // tarjeta arriba
494
506
  const afterId = idx < colList.length ? colList[idx].id : null // tarjeta abajo
495
507
 
496
- if (fromState === targetState && beforeId == null && afterId == null) return
497
-
498
508
  const snapshot = rows.value.map(r => ({ ...r }))
499
509
  const ridx = rows.value.findIndex(r => r.id === id)
500
510
  if (ridx >= 0) {
@@ -509,7 +519,13 @@ const onDrop = async (targetState) => {
509
519
  emit('move', { id, from: fromState, to: targetState })
510
520
 
511
521
  try {
512
- await api.post(props.reorderEndpoint, { id, column: targetState, before_id: beforeId, after_id: afterId })
522
+ const res = await api.post(props.reorderEndpoint, { id, column: targetState, before_id: beforeId, after_id: afterId })
523
+ // Reconciliar con la posición canónica del server (por si rebalanceó).
524
+ const saved = res?.data ?? res
525
+ if (saved && saved.position != null) {
526
+ const r = rows.value.findIndex(x => x.id === id)
527
+ if (r >= 0) rows.value[r] = { ...rows.value[r], position: saved.position, [props.stateKey]: saved[props.stateKey] ?? targetState }
528
+ }
513
529
  } catch (e) {
514
530
  rows.value = snapshot
515
531
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@innertia-solutions/innertia-nuxt",
3
- "version": "0.1.40",
3
+ "version": "0.1.41",
4
4
  "description": "Innertia Solutions — Nuxt layer unificada: core, auth, multitenancy, theme y app contexts",
5
5
  "keywords": [
6
6
  "nuxt",