Skip to main content

LgSummaryBox

LgSummaryBox displays a long text on a single line (truncated) and opens a modal window to edit it, in a multiline text area or an HTML editor. The input is applied to the bound value only upon validation by the modal's "Save" button.

<LgSummaryBox Label="#Comment" @bind-Value="_model.Comment" />
  • Namespace: Lagoon.UI.Components
  • Inherits from: LgInputRenderBase<string> → LgInputBase<string> → LgAriaComponentBase → LgComponentBase
  • NuGet package: Lagoon.UI

The standard field reset button (ResetButton) is never displayed: reset is performed through the modal's "Clear" button.

Usage​

Demonstration​

Try this component in the Lagoon showcase.

Clicking on the field (or pressing Enter when it has focus) opens the modal. ModalTitle replaces the Label as the title and ModalSize sets the window size. If the user closes the modal with unsaved changes, they are asked for confirmation.

ReportPage.razor
<LgSummaryBox Label="#Summary"
ModalTitle="#EditSummary"
ModalSize="ModalSize.ExtraLarge"
TextareaHeight="300"
MaxLength="2000"
@bind-Value="_model.Summary" />
ReportPage.razor.cs
public partial class ReportPage : LgPage
{
private readonly ReportVm _model = new();

private sealed class ReportVm
{
public string Summary { get; set; }
}
}

Opening on focus and multiline display​

OpenOnFocus opens the modal as soon as the field receives focus (useful in a keyboard navigation flow). WrapContent displays the value on multiple lines instead of truncating it.

NotePage.razor
<LgSummaryBox Label="#Note"
OpenOnFocus="true"
WrapContent="true"
OnOpen="OnNoteOpen"
OnClose="OnNoteClose"
@bind-Value="_model.Note" />
NotePage.razor.cs
public partial class NotePage : LgPage
{
private readonly NoteVm _model = new();

// Triggered when the modal opens: useful for logging or loading a context.
private void OnNoteOpen()
{
ShowInformation("#NoteOpened");
}

// Triggered when the modal closes (after validation or cancel).
private void OnNoteClose()
{
ShowInformation("#NoteClosed");
}

private sealed class NoteVm
{
public string Note { get; set; }
}
}

HTML editor​

UseHtmlEditor="true" replaces the text area with an HTML editor (LgHtmlEditor); the bound value then contains HTML, rendered as-is in the field. HtmlEditorButtons restricts the toolbar buttons.

DescriptionPage.razor
<LgSummaryBox Label="#Description"
UseHtmlEditor="true"
HtmlEditorButtons="_editorButtons"
@bind-Value="_model.DescriptionHtml" />
DescriptionPage.razor.cs
public partial class DescriptionPage : LgPage
{
// Reduced toolbar: only authorized enhancements are offered.
private readonly List<string> _editorButtons = new() { "bold", "italic", "underline", "ul", "ol" };

private readonly DescriptionVm _model = new();

private sealed class DescriptionVm
{
public string DescriptionHtml { get; set; }
}
}

Cancel a value change​

OnChangingAsync is called when the modal is validated, before the new value is assigned, and allows you to cancel it (args.Cancel).

JustificationPage.razor
<LgSummaryBox Label="#Justification"
OnChangingAsync="OnJustificationChangingAsync"
@bind-Value="_model.Justification" />
JustificationPage.razor.cs
public partial class JustificationPage : LgPage
{
private readonly JustificationVm _model = new();

// Called before assignment: enforces minimum content at save.
private Task OnJustificationChangingAsync(ChangingEventArgs<string> args)
{
if (string.IsNullOrWhiteSpace(args.NewValue) || args.NewValue.Length < 20)
{
args.Cancel = true;
ShowWarning("#JustificationTooShort");
}
return Task.CompletedTask;
}

private sealed class JustificationVm
{
public string Justification { get; set; }
}
}

Properties​

All [Parameter] properties of the component, including inherited ones.

NameTypeDefaultDeclared inDescription
HtmlEditorButtonsList<string>nullLgSummaryBoxToolbar buttons for the HTML editor. If null, the full toolbar is displayed.
MaxLengthint?nullLgSummaryBoxMaximum number of characters entered.
ModalSizeModalSizeLargeLgSummaryBoxSize of the editing modal window.
ModalTitlestringnullLgSummaryBoxModal title. If null, the field's Label is used.
OnChangingAsyncFunc<ChangingEventArgs<string>, Task>nullLgSummaryBoxCallback called before the value changes; the change can be cancelled there.
OnCloseEventCallback—LgSummaryBoxCallback called when the modal closes.
OnFocusEventCallback<FocusEventArgs>—LgSummaryBoxCallback called when focus is received.
OnKeyUpEventCallback<KeyboardEventArgs>—LgSummaryBoxCallback called when a key is released.
OnOpenEventCallback—LgSummaryBoxCallback called when the modal opens.
OpenOnFocusboolfalseLgSummaryBoxOpens the modal as soon as the field receives focus.
PlaceholderstringnullLgSummaryBoxHint text displayed when the field is empty.
TextareaHeightint0LgSummaryBoxHeight of the modal text area, in pixels.
UseHtmlEditorboolfalseLgSummaryBoxReplaces the text area with an HTML editor.
WrapContentboolfalseLgSummaryBoxDisplays the value on multiple lines instead of truncating it.
PrefixstringnullLgInputRenderBasePrefix displayed in the field.
PrefixTypeInputLabelTypeTextLgInputRenderBaseType of the prefix.
SuffixstringnullLgInputRenderBaseSuffix displayed in the field.
SuffixTypeInputLabelTypeTextLgInputRenderBaseType of the suffix.
AdditionalAttributesIReadOnlyDictionary<string, object>nullLgInputBaseAdditional HTML attributes applied to the rendered element.
AutoFocusboolfalseLgInputBaseGives focus to the field on first render.
ConfirmationMessagestringnullLgInputBaseConfirmation message displayed before applying a value change.
ContainerIInputContainer<string>nullLgInputBaseInternal use: attaches a GridView cell to the field.
CssClassstringnullLgInputBaseAdditional CSS classes.
DisabledboolfalseLgInputBaseDisables the field.
DisplayNamestringnullLgInputBaseField name used in error messages.
HideValidationMessageboolfalseLgInputBaseHides the validation message below the field.
LabelstringnullLgInputBaseField label.
LabelContentRenderFragmentnullLgInputBaseCustom content for the label area.
OnChangeEventCallback<ChangeEventArgs>—LgInputBaseCallback called after the value changes.
OnResetEventCallback<ChangeEventArgs>—LgInputBaseCallback called on reset (no effect here, the standard reset button is not displayed).
PolicyEditstringnullLgInputBasePolicy required to edit the field.
PolicyVisiblestringnullLgInputBasePolicy required to display the field.
ReadOnlyboolfalseLgInputBaseDisplays the value as read-only (the modal remains readable).
Requiredbool?nullLgInputBaseRequired field. If null, inferred from the [Required] attribute of the bound property.
ResetButtonbool?nullLgInputBaseNo effect: the standard reset button is never displayed by this component.
ResetTextstringnullLgInputBaseText for the reset button (no effect here).
ResetTextAriaLabelstringnullLgInputBaseAccessible label for the reset button (no effect here).
TooltipstringnullLgInputBaseTooltip.
TooltipIsHtmlboolfalseLgInputBaseIndicates whether the Tooltip content is in HTML format (otherwise plain text).
ValuestringnullLgInputBaseBound value (@bind-Value).
ValueChangedEventCallback<string>—LgInputBaseCallback to update the bound value.
ValueExpressionExpression<Func<string>>—LgInputBaseExpression identifying the bound property.
AriaLabelstringnullLgAriaComponentBaseValue of the aria-label attribute.
AriaLabelledBystringnullLgAriaComponentBaseValue of the aria-labelledby attribute.
Cascading parameters

LgSummaryBox also consumes parameters automatically provided by ancestor components (you do not need to set them): ParentAuthorizeView (LgAuthorizeView) and the edit context of a parent LgEditForm.

Events​

EventTypeDescription
OnOpenEventCallbackWhen the edit modal opens.
OnCloseEventCallbackWhen the edit modal closes.
OnChangingAsyncFunc<ChangingEventArgs<string>, Task>Before the new value is assigned; args.Cancel = true cancels it.
OnChangeEventCallback<ChangeEventArgs>After the new value is assigned.
OnKeyUpEventCallback<KeyboardEventArgs>When a key is released on the field.
OnFocusEventCallback<FocusEventArgs>When the field receives focus.

Best practices / accessibility​

  • Reserve UseHtmlEditor for truly enriched content: the bound value then contains HTML that must be sanitized before any other use.
  • For a short multiline text, editable in place, prefer LgTextBox with TextMode="TextBoxMode.Multiline".
Complete reference

All parameters (including inherited ones): API reference — LgSummaryBox.