mirror of
https://github.com/freedbygrace/ActiveDirectoryManager.git
synced 2026-07-27 04:19:39 +00:00
Fix: Correctly remove individual condition groups in dynamic group management.
Replit-Commit-Author: Agent Replit-Commit-Session-Id: 705f2157-ef97-4fbd-89e4-8c7f2ecaea90 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/7ed01c5f-a82d-405a-b728-b2e3d127c60c/db1eab1f-8099-4fb2-b481-6a4be55316dc.jpg
This commit is contained in:
@@ -159,10 +159,22 @@ const ConditionBuilder: React.FC<ConditionBuilderProps> = ({
|
||||
}
|
||||
}
|
||||
|
||||
// Remove the group and all its children
|
||||
const newConditions = conditions.filter(
|
||||
c => c.id !== conditionToRemove.id && c.parentId !== conditionToRemove.id
|
||||
);
|
||||
// Find just this group's children (not all groups with the same parent)
|
||||
const childrenToRemove = conditions.filter(c => c.parentId === conditionToRemove.id);
|
||||
|
||||
// Create a list of IDs to remove (the group and its direct children)
|
||||
const idsToRemove = new Set([
|
||||
conditionToRemove.id,
|
||||
...childrenToRemove.map(c => c.id).filter(Boolean)
|
||||
]);
|
||||
|
||||
// Only remove this specific group and its direct children
|
||||
const newConditions = conditions.filter(c => {
|
||||
// Keep the condition if its ID is not in our removal list
|
||||
// and its parent ID is not the ID of the group we're removing
|
||||
return !idsToRemove.has(c.id) && c.parentId !== conditionToRemove.id;
|
||||
});
|
||||
|
||||
onChange(newConditions);
|
||||
} else {
|
||||
// Just remove the single condition
|
||||
|
||||
Reference in New Issue
Block a user