Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,17 @@ protected override void OnApplyTemplate()
{
content.ContentTemplate = new FieldTemplateSelector(this);
}

// JH: If UpdateErrorMessages is called before the FieldFormElementView is Loaded it fails
Loaded += OnLoaded;
UpdateErrorMessages();
}

private void OnLoaded(object? sender, EventArgs e)
{
UpdateErrorMessages();
Loaded -= OnLoaded;
}
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ private void UpdateErrorMessages()
}
if (GetTemplateChild("ErrorLabel") is TextBlock tb)
{
// JH: If the control is not loaded yet, updating error message will fail.
if ( !IsLoaded ) return;

tb.Text = errMessage ?? string.Empty;
bool showError = false;
if (!string.IsNullOrEmpty(errMessage) && (_hadFocus || FeatureFormView.GetFeatureFormViewParent(this)?.ShouldShowError() == true))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,14 @@ protected override void OnApplyTemplate()
button.Clicked += BarcodeButton_Clicked;
}
ConfigureTextBox();

//JH: Same issue as in FieldFormElement, the first time UpdateValidationState is called Element is null
Loaded += OnLoaded;
UpdateValidationState();
}

private void OnLoaded(object? sender, EventArgs e)
{
UpdateValidationState();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,11 +364,15 @@ private void Element_PropertyChanged(object? sender, System.ComponentModel.Prope
this.Dispatch(UpdateValidationState);
}
}

private void UpdateValidationState()
{
var err = Element?.ValidationErrors;
if (err != null && err.Any() && Element?.IsEditable == true && _hadFocus)

//JH: Add a check to see if the ErrorsVisibility is set to true, not only if _hadFocus is true
bool shouldShowError = (FeatureFormView.GetFeatureFormViewParent(this)?.ShouldShowError() ?? false) || _hadFocus;

if (err != null && err.Any() && Element?.IsEditable == true && shouldShowError)
{
#if MAUI
if (GetTemplateChild("ErrorBorder") is Border border)
Expand Down