Skip to content

Fix: field drag-and-drop reorder throws "Unknown field" RuntimeException#1166

Open
jbonor wants to merge 1 commit intopluginsGLPI:mainfrom
jbonor:fix/reorder-dom-index-mismatch
Open

Fix: field drag-and-drop reorder throws "Unknown field" RuntimeException#1166
jbonor wants to merge 1 commit intopluginsGLPI:mainfrom
jbonor:fix/reorder-dom-index-mismatch

Conversation

@jbonor
Copy link

@jbonor jbonor commented Mar 19, 2026

fixes #1146

The REDIPS drag-and-drop library sends 1-based DOM row indices as
old_order/new_order, but reorder.php treated them as database ranking
values. When rankings have gaps (from deletions or prior reorders),
DOM indices diverge from stored rankings, causing the query
WHERE ranking = old_order to find no matching field.

Refactor reorder.php to accept positional indices: retrieve all fields
ordered by ranking ASC, map them to 1-based positions matching REDIPS
row indices, reorder via array manipulation, and persist with normalized
contiguous rankings. This also auto-repairs ranking gaps on every
reorder operation.

Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com

@stonebuzz
Copy link
Contributor

Several issues:

  • This approach does not address the root cause of the problem; it feels more like a temporary patch than a true fix.
  • Systematic updates of rankings for all fields.

JS now reads data-ranking from table rows instead of using DOM indices,
decoupling REDIPS row positions from backend ranking values. Migration
normalizes rankings to contiguous 0-based values per container.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jbonor jbonor force-pushed the fix/reorder-dom-index-mismatch branch from 806fa54 to 5202179 Compare March 19, 2026 11:17
@jbonor
Copy link
Author

jbonor commented Mar 19, 2026

Updated patch with a better approach that takes into consideration your issues I hope

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reordering fields does not work always

2 participants