From 965b4b5f985fed78a4214bdc909d7e10921be180 Mon Sep 17 00:00:00 2001 From: Kurisu <69393463+soma-kurisu@users.noreply.github.com> Date: Sat, 17 Feb 2024 19:30:24 +0100 Subject: [PATCH] ensure delegate isn't null and does'nt throw --- .../OptionEditor.razor | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/OrchardCore.Components/OrchardCore.Common.Components/OptionEditor.razor b/src/OrchardCore.Components/OrchardCore.Common.Components/OptionEditor.razor index 2183b811b8b..c1a1393064e 100644 --- a/src/OrchardCore.Components/OrchardCore.Common.Components/OptionEditor.razor +++ b/src/OrchardCore.Components/OrchardCore.Common.Components/OptionEditor.razor @@ -173,12 +173,24 @@ private async Task OptionItemChangeAsync(Action update) { - update(); + // validate provided delegate + if (update is not null) + { + try + { + update(); + } + catch(Exception) + { + // ignore + } + } + + // Options may have changed independent of "update" delegate, e.g. inline, so we apply update routine anyway TryUpdateOptionsJson(Options); await TriggerEventAsync(); } - protected override Task OnInitializedAsync() { SetOptionsEmpty();