prevent moving a category into one of its own descendants (#2355)

This commit is contained in:
Athou
2026-10-30 20:51:45 +01:00
parent 20ec5d3eb9
commit fa8a447787
2 changed files with 17 additions and 1 deletions

View File

@@ -37,6 +37,9 @@ export function CategoryDetailsPage() {
category = query.result && flattenCategoryTree(query.result.data).find(c => c.id === id)
}
// a category cannot be moved under itself or one of its own descendants
const excludedCategoryIds = category ? flattenCategoryTree(category).map(c => c.id) : [id]
const form = useForm<CategoryModificationRequest>()
const { setValues } = form
@@ -125,7 +128,7 @@ export function CategoryDetailsPage() {
label={<Trans>Parent Category</Trans>}
{...form.getInputProps("parentId")}
clearable
withoutCategoryIds={[id]}
withoutCategoryIds={excludedCategoryIds}
/>
<NumberInput label={<Trans>Position</Trans>} {...form.getInputProps("position")} required min={0} />
</>