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:
@@ -82,7 +82,15 @@
|
|||||||
|
|
||||||
if (this.ModalService.Current is { } current)
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user