-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clear Signature Programmatically #26
Comments
Hi! Thanks for contacting me. I will try and take a look on this by tomorrow. It would help me a lot if you could provide a small example repository as I'm not this familiar with MudBlazor. Thanks! |
Good morning! Please try this one out: @using MudBlazor
@using SignaturePad
<MudDialog>
<DialogContent>
<SignaturePad @ref="_signaturePad" @bind-Value="bSignature" ShowClearButton="false" style="max-width: calc(100vw - 3rem); width: 800px" />
</DialogContent>
<DialogActions>
<MudButton OnClick="Clear">Clear</MudButton>
<MudSpacer />
<MudButton OnClick="Cancel">Cancel</MudButton>
<MudButton Color="Color.Error" OnClick="Submit">Sign Document</MudButton>
</DialogActions>
</MudDialog>
@code {
[CascadingParameter] MudDialogInstance MudDialog { get; set; }
public byte[] bSignature { get; set; } = Array.Empty<byte>();
public string SignatureAsBase64 => System.Text.Encoding.UTF8.GetString(bSignature);
private SignaturePad _signaturePad = default!;
protected override void OnInitialized() {
}
void Submit() => MudDialog.Close(DialogResult.Ok(true));
void Cancel() => MudDialog.Cancel();
private async Task Clear() {
await _signaturePad.Clear();
Console.WriteLine($"Signature cleared {bSignature.Length}");
StateHasChanged();
}
} |
Hi @mouse0270, you can also try to re-render the dialog after clean, there is a method in MudDialogInstance, to force re-render of the component. |
I am using MudBlazor Dialog to show the
SignaturePad
and this appears to work as expected. The Dialog is showing up and I can use the Signature pad. The problem becomes when I want to clear it. I setShowClearButton
tofalse
and then added a dialog button for clear, so the UI will flow as expected. However, when the user hits the clear button, theSignaturePad
keeps the data.I can see that the console outputs a length of
0
after setting the array toArray.Empty<byte>()
but theSignaturePad
does not appear to update to show this.#12 is where I got the idea to clear set the Byte to an empty array to clear the signature pad, also I am using version 8.0.0
The text was updated successfully, but these errors were encountered: