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; } }