From 812d873d5d24442f78976977972e6368c761dd68 Mon Sep 17 00:00:00 2001 From: Thibaut Valentin Date: Sun, 8 Mar 2026 21:58:57 +0100 Subject: [PATCH] fix: Match reorder refresh --- .../src/pages/competition/editor/CategoryAdminContent.jsx | 4 +++- src/main/webapp/src/utils/MatchReducer.jsx | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/webapp/src/pages/competition/editor/CategoryAdminContent.jsx b/src/main/webapp/src/pages/competition/editor/CategoryAdminContent.jsx index 95ed1ab..b7abacc 100644 --- a/src/main/webapp/src/pages/competition/editor/CategoryAdminContent.jsx +++ b/src/main/webapp/src/pages/competition/editor/CategoryAdminContent.jsx @@ -568,7 +568,9 @@ function MatchList({matches, cat, groups, reducer, classement = false}) { const {active, over} = event; if (active.id !== over.id) { - const newIndex = marches2.findIndex(m => m.id === over.id); + let newIndex = marches2.findIndex(m => m.id === over.id); + if (newIndex > 0) + newIndex = marches2[newIndex].categorie_ord; reducer({type: 'REORDER', payload: {id: active.id, pos: newIndex}}); sendRequest('updateMatchOrder', {id: active.id, pos: newIndex}).then(__ => { }) diff --git a/src/main/webapp/src/utils/MatchReducer.jsx b/src/main/webapp/src/utils/MatchReducer.jsx index 20e7514..e591d73 100644 --- a/src/main/webapp/src/utils/MatchReducer.jsx +++ b/src/main/webapp/src/utils/MatchReducer.jsx @@ -56,8 +56,10 @@ export function MarchReducer(datas, action) { return datas.sort(action.payload) case 'REORDER': const oldIndex = datas.findIndex(data => data.id === action.payload.id) - if (oldIndex === -1 || datas[oldIndex].categorie_ord === action.payload.pos) + if (oldIndex === -1) return datas // Do nothing + if (datas[oldIndex].categorie_ord === action.payload.pos) + return [...datas] // Do nothing const oldPos = datas[oldIndex].categorie_ord const newPos = action.payload.pos