I have a component called ImageUpload that handles pictures upload and then emit the values. I use that component inside a component called IngredientForm and it works, the problem is inside IngredientForm there's another component called ModifyIngredientModal where i use ImageUpload again and when the event is emitted from there then it's handled with the method i've wrote inside IngredientForm and not the one from ModifyIngredientModal.
Basically the grand-parent is handling the child event instead of the parent.
this is the code of ModifyIngredientModal
<app-image-upload
[label]="'recipes.editor.ingredients.picture' | transloco"
[inputName]="'ingredientPicture'"
(photoUploaded)="uploadNewPicture($event)">
</app-image-upload>
uploadNewPicture(uploadedPictures: customFile[]) {
console.log("MODIFY")
if (uploadedPictures[0]) {
this.ingredientPicture = uploadedPictures[0];
this.ingredientForm.controls.ingredientPicture.setValue(true)
} else {
this.ingredientForm.controls.ingredientPicture.setValue(false)
}
}
and this is the one from IngredientForm
<app-image-upload
#ingredientPictureUpload
[label]="'recipes.editor.ingredients.picture' | transloco"
[inputName]="'ingredientPicture'"
(photoUploaded)="getIngredientUploadedPhoto($event)">
</app-image-upload>
getIngredientUploadedPhoto(uploadedPictures: customFile[]) {
console.log("FORM")
if (uploadedPictures[0]) {
this.ingredientPicture = uploadedPictures[0];
this.ingredientForm.controls.ingredientPicture.setValue(true)
} else {
this.ingredientPicture = null;
this.ingredientForm.controls.ingredientPicture.setValue(false)
}
}
in the console i can only see FORM printed, i was expecting that the parent would handle the event and it stops there, i could understand the event being handled by both of them but surely not having only the grand parent handling it