From 2605e05a980c050d86a95e90c4b113706d106428 Mon Sep 17 00:00:00 2001 From: Sven <40752681+NeoCoderMatrix86@users.noreply.github.com> Date: Wed, 30 Apr 2025 16:12:26 +0200 Subject: [PATCH] Update CuesheetData.razor --- .../Shared/Cuesheet/CuesheetData.razor | 40 ++++++++++++++----- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/AudioCuesheetEditor/Shared/Cuesheet/CuesheetData.razor b/AudioCuesheetEditor/Shared/Cuesheet/CuesheetData.razor index dea1a839..4a998279 100644 --- a/AudioCuesheetEditor/Shared/Cuesheet/CuesheetData.razor +++ b/AudioCuesheetEditor/Shared/Cuesheet/CuesheetData.razor @@ -26,7 +26,7 @@ along with Foobar. If not, see @if (Cuesheet != null) { - + @switch(CurrentViewMode) @@ -51,6 +51,7 @@ along with Foobar. If not, see string? fileInputAudiofileId; string? fileInputAudiofileErrorText; string? fileInputCDTextfileErrorText; + MudForm? form; protected override void OnInitialized() { @@ -61,6 +62,16 @@ along with Foobar. If not, see } } + protected override async Task OnAfterRenderAsync(bool firstRender) + { + await base.OnAfterRenderAsync(firstRender); + if (form != null) + { + await form.Validate(); + SetAudiofileValidationText(); + } + } + async Task OnAudiofileSelected(IBrowserFile? browserFile) { if (Cuesheet == null) @@ -83,15 +94,24 @@ along with Foobar. If not, see // Just validate the cuesheet if there is no error already if (fileInputAudiofileErrorText == null) { - var validationMessages = _validationService.Validate(Cuesheet, nameof(Cuesheet.Audiofile)); - if (validationMessages.Count() > 0) - { - fileInputAudiofileErrorText = String.Join(Environment.NewLine, validationMessages); - } - else - { - fileInputAudiofileErrorText = null; - } + SetAudiofileValidationText(); + } + } + + void SetAudiofileValidationText() + { + if (Cuesheet == null) + { + return; + } + var validationMessages = _validationService.Validate(Cuesheet, nameof(Cuesheet.Audiofile)); + if (validationMessages.Count() > 0) + { + fileInputAudiofileErrorText = String.Join(Environment.NewLine, validationMessages); + } + else + { + fileInputAudiofileErrorText = null; } }