diff --git a/antarest/study/storage/variantstudy/model/command/remove_area.py b/antarest/study/storage/variantstudy/model/command/remove_area.py index ae1ad52c12..82d9a9d704 100644 --- a/antarest/study/storage/variantstudy/model/command/remove_area.py +++ b/antarest/study/storage/variantstudy/model/command/remove_area.py @@ -132,8 +132,12 @@ def _apply(self, study_data: FileStudy) -> CommandOutput: ) del study_data.config.areas[self.id] - for area_name in study_data.config.areas.keys(): - study_data.tree.delete(["input", "links", area_name, self.id]) + for area_name, area in study_data.config.areas.items(): + for link in area.links.keys(): + if link == self.id: + study_data.tree.delete( + ["input", "links", area_name, self.id] + ) new_area_data: JSON = { "input": {