Skip to content

Commit

Permalink
Accordion item Disabled property added
Browse files Browse the repository at this point in the history
Close #1861
  • Loading branch information
enchev committed Dec 18, 2024
1 parent 0c56f20 commit 1ceaab2
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Radzen.Blazor/RadzenAccordion.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ protected string ItemAriaLabel(int index, RadzenAccordionItem item)

internal async System.Threading.Tasks.Task SelectItem(RadzenAccordionItem item, bool? value = null)
{
if(item.Disabled) return;

await CollapseAll(item);

var itemIndex = items.IndexOf(item);
Expand Down
7 changes: 7 additions & 0 deletions Radzen.Blazor/RadzenAccordionItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ public partial class RadzenAccordionItem : RadzenComponent
[Parameter]
public bool Selected { get; set; }

/// <summary>
/// Gets or sets a value indicating whether this <see cref="RadzenAccordionItem"/> is disabled.
/// </summary>
/// <value><c>true</c> if disabled; otherwise, <c>false</c>.</value>
[Parameter]
public bool Disabled { get; set; }

/// <summary>
/// Gets or sets the title attribute of the expand button.
/// </summary>
Expand Down
26 changes: 26 additions & 0 deletions RadzenBlazorDemos/Pages/AccordionDisableExpandCollapse.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

<RadzenStack class="rz-p-0 rz-p-md-12">
<RadzenCard class="rz-p-4" Variant="Variant.Outlined">
<RadzenStack Orientation="Orientation.Vertical" Gap="4px">
<RadzenLabel Text="Expand/Collapse enabled:" />
<RadzenSwitch @bind-Value="canCollapse" />
</RadzenStack>
</RadzenCard>
<RadzenAccordion>
<Items>
<RadzenAccordionItem Disabled="@(!canCollapse)" Text="Orders" Icon="account_balance_wallet">
Details for Orders
</RadzenAccordionItem>
<RadzenAccordionItem Disabled="@(!canCollapse)" Text="Employees" Icon="account_box">
Details for Employees
</RadzenAccordionItem>
<RadzenAccordionItem Disabled="@(!canCollapse)" Text="Customers" Icon="accessibility">
Details for Customers
</RadzenAccordionItem>
</Items>
</RadzenAccordion>
</RadzenStack>

@code {
bool canCollapse = true;
}
6 changes: 6 additions & 0 deletions RadzenBlazorDemos/Pages/AccordionPage.razor
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@
<AccordionEvents />
</RadzenExample>

<RadzenText Anchor="accordion#expand-collapse-events" TextStyle="TextStyle.H5" TagName="TagName.H2" class="rz-pt-8 rz-mb-6">
Disable expand/collapse
</RadzenText>
<RadzenExample ComponentName="Accordion" Example="AccordionDisableExpandCollapse">
<AccordionDisableExpandCollapse />
</RadzenExample>
<RadzenText Anchor="accordion#keyboard-navigation" TextStyle="TextStyle.H5" TagName="TagName.H2" class="rz-pt-12">
Keyboard Navigation
</RadzenText>
Expand Down

0 comments on commit 1ceaab2

Please sign in to comment.