-
Notifications
You must be signed in to change notification settings - Fork 79
Adjust Signature PanelBar KB sample behavior and normalize article metadata #3665
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
Merged
IvanDanchev
merged 5 commits into
master
from
copilot/fix-signature-component-in-panelbar
Jun 3, 2026
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5ddae90
Add KB article for Signature offset strokes in PanelBar ContentTemplate
Copilot 8dcd3ef
Expand Signature item by default in KB example
Copilot 134dd83
Update Signature PanelBar KB metadata values
Copilot f48784d
Update Signature PanelBar KB example per review
Copilot 875b853
Replace KB sample structure per review
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
164 changes: 164 additions & 0 deletions
164
knowledge-base/signature-panelbar-contenttemplate-offset-strokes.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,164 @@ | ||
| --- | ||
| title: Signature Strokes Are Offset in PanelBar ContentTemplate | ||
| description: Learn how to render the Telerik Signature in a PanelBar ContentTemplate after the expand animation completes, so the Signature canvas initializes with correct dimensions. | ||
| type: troubleshooting | ||
| page_title: Signature Strokes Are Offset in PanelBar ContentTemplate | ||
| slug: signature-kb-panelbar-contenttemplate-offset-strokes | ||
| tags: telerik, blazor, signature, panelbar, contenttemplate | ||
| ticketid: 1712712 | ||
| res_type: kb | ||
| components: ["signature","panelbar"] | ||
| --- | ||
| ## Environment | ||
|
|
||
| <table> | ||
| <tbody> | ||
| <tr> | ||
| <td>Product</td> | ||
| <td>UI for Blazor</td> | ||
| </tr> | ||
| </tbody> | ||
| </table> | ||
|
|
||
| ## Description | ||
|
|
||
| This article answers the following questions: | ||
|
|
||
| * Why does the Signature line look zoomed in when the component is inside a PanelBar item? | ||
| * Why is the Signature stroke offset from the pointer in a PanelBar `ContentTemplate`? | ||
| * How can you initialize Signature after PanelBar expand animation completes? | ||
|
|
||
| ## Cause | ||
|
|
||
| When you place a `TelerikSignature` inside a PanelBar `ContentTemplate`, the Signature canvas can initialize while the PanelBar expand animation is still running. At that time, the container can have zero or partial height. The Signature JavaScript reads incorrect dimensions and the drawn line appears zoomed and offset from the cursor. | ||
|
|
||
| ## Solution | ||
|
|
||
| Render the Signature only after the PanelBar animation ends: | ||
|
|
||
| 1. Keep a `ShowSignature` flag set to `false` only when the user starts expanding the Signature item. | ||
| 1. In `OnAfterRenderAsync`, wait for the animation duration (`Task.Delay(100)` in this example), then set `ShowSignature` to `true`. | ||
| 1. Use a version counter to ignore stale delayed completions if the user expands or collapses again before the delay finishes. | ||
|
|
||
| >caption Delay Signature rendering until PanelBar animation completes | ||
|
|
||
| ````RAZOR | ||
| <div class="panelbar-template"> | ||
| <TelerikPanelBar Data="@PanelBarData" | ||
| ExpandedItems="@ExpandedItems" | ||
| ExpandedItemsChanged="@OnExpandedItemsChanged"> | ||
| <PanelBarBindings> | ||
| <PanelBarBinding ItemsField="@nameof(PanelBarItem.Items)"> | ||
| <ContentTemplate> | ||
| @{ | ||
| var item = (PanelBarItem)context; | ||
| } | ||
|
|
||
| @if (item.Text == "Sign Here") | ||
| { | ||
| if (ShowSignature) | ||
| { | ||
| <TelerikSignature @bind-Value="@SignatureValue" | ||
| Width="320px" | ||
| Height="180px" /> | ||
| } | ||
| } | ||
| else | ||
| { | ||
| <div>@item.Text</div> | ||
| } | ||
| </ContentTemplate> | ||
| </PanelBarBinding> | ||
| </PanelBarBindings> | ||
| </TelerikPanelBar> | ||
| </div> | ||
|
|
||
| <style> | ||
| .panelbar-template { | ||
| margin: 0 auto; | ||
| width: 400px; | ||
| } | ||
| </style> | ||
|
|
||
| @code { | ||
| private List<PanelBarItem> PanelBarData { get; set; } = new(); | ||
| private IEnumerable<object> ExpandedItems { get; set; } = new List<object>(); | ||
| private string SignatureValue { get; set; } = string.Empty; | ||
|
|
||
| private bool ShowSignature { get; set; } | ||
| private bool ShowSignaturePending { get; set; } | ||
| private int SignatureVersion { get; set; } | ||
|
|
||
| private PanelBarItem? SignatureItem { get; set; } | ||
|
|
||
| private void OnExpandedItemsChanged(IEnumerable<object> items) | ||
| { | ||
| var expandedList = items.ToList(); | ||
|
|
||
| bool signatureWasExpanded = ExpandedItems.Contains(SignatureItem); | ||
| bool signatureIsExpanding = SignatureItem != null && expandedList.Contains(SignatureItem); | ||
|
|
||
| ExpandedItems = expandedList; | ||
|
|
||
| if (!signatureWasExpanded && signatureIsExpanding) | ||
| { | ||
| ShowSignature = false; | ||
| ShowSignaturePending = true; | ||
| } | ||
| } | ||
|
|
||
| private void LoadData() | ||
| { | ||
| SignatureItem = new PanelBarItem { Text = "Sign Here" }; | ||
|
|
||
| PanelBarData = new List<PanelBarItem> | ||
| { | ||
| new() { Text = "Documents" }, | ||
| new() { Text = "Reports" }, | ||
| SignatureItem, | ||
| new() { Text = "Settings" } | ||
| }; | ||
|
|
||
| ExpandedItems = new List<object> { SignatureItem }; | ||
| } | ||
|
|
||
| protected override void OnInitialized() | ||
| { | ||
| LoadData(); | ||
| ShowSignature = false; | ||
| ShowSignaturePending = true; | ||
| } | ||
|
|
||
| protected override async Task OnAfterRenderAsync(bool firstRender) | ||
| { | ||
| if (firstRender || ShowSignaturePending) | ||
| { | ||
| ShowSignaturePending = false; | ||
|
|
||
| var version = ++SignatureVersion; | ||
| await Task.Delay(100); | ||
|
|
||
| if (SignatureVersion == version) | ||
| { | ||
| ShowSignature = true; | ||
| StateHasChanged(); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| public class PanelBarItem | ||
| { | ||
| public string Text { get; set; } = string.Empty; | ||
| public List<PanelBarItem>? Items { get; set; } | ||
| } | ||
| } | ||
| ```` | ||
|
|
||
| The `Task.Delay` value must match your PanelBar animation duration. If you use a different animation setup, increase or decrease the delay accordingly. | ||
|
|
||
| ## See Also | ||
|
|
||
| * [Signature Overview](slug:signature-overview) | ||
| * [PanelBar Content Template](slug:panelbar-templates-content) | ||
| * [PanelBar Events](slug:panelbar-events) | ||
| * [Resize Signature with the Browser](slug:signature-kb-relative-width-height) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.