Merge pull request #830 from valentinoConti/fix/modals-crashing-app

Fix modals making app crash

(cherry picked from commit 55ac67312448f4d851c44a1c77734703c9b1d3dd)
This commit is contained in:
sven-n
2026-07-15 21:51:36 +02:00
committed by Acentech Dev
parent a76647265c
commit e9aec9540f

View File

@@ -82,7 +82,15 @@
if (this.ModalService.Current is { } current)
{
result["Modal"] = current.Instance;
// Only supply the Modal instance to content components that actually declare
// a matching parameter (e.g. ModalQuestion). Passing it to a component that
// doesn't - like the plain ModalMessage - makes Blazor throw "does not have a
// property matching the name 'Modal'". This keeps simple modals boilerplate-free.
var modalProperty = current.ComponentType.GetProperty("Modal");
if (modalProperty is not null && modalProperty.PropertyType.IsAssignableFrom(typeof(ModalInstance)))
{
result["Modal"] = current.Instance;
}
}
return result;
}