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