Skip to content

Commit

Permalink
Merge pull request #79 from codersyntax/change-to-dropdown-item-event
Browse files Browse the repository at this point in the history
Resolve Issue 78 : DropdownItem Click Event Parameter Type Issue
  • Loading branch information
emncnozge authored Sep 3, 2024
2 parents 7785c04 + 9547b66 commit b638b2b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions SiemensIXBlazor.Tests/Dropdown/DropdownItemTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ public async Task EventCallbacksAreTriggeredCorrectly()

var cut = RenderComponent<DropdownItem>(parameters => parameters
.Add(p => p.OnClickEvent,
EventCallback.Factory.Create<string>(this, label => isOnClickEventTriggered = true)));
EventCallback.Factory.Create<DropdownItem>(this, label => isOnClickEventTriggered = true)));

// Act
await cut.Instance.OnClickEvent.InvokeAsync("testLabel");
await cut.Instance.OnClickEvent.InvokeAsync(cut.Instance);

// Assert
Assert.True(isOnClickEventTriggered);
Expand Down
2 changes: 1 addition & 1 deletion SiemensIXBlazor/Components/Dropdown/DropdownItem.razor
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ style="@Style"
class="@Class"
label="@Label"
value="@Value"
@onclick="() => Clicked(Label)">
@onclick="() => Clicked(this)">
</ix-dropdown-item>
6 changes: 3 additions & 3 deletions SiemensIXBlazor/Components/Dropdown/DropdownItem.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ public partial class DropdownItem
[Parameter]
public string Value { get; set; } = string.Empty;
[Parameter]
public EventCallback<string> OnClickEvent { get; set; }
public EventCallback<DropdownItem> OnClickEvent { get; set; }

private async void Clicked(string label)
private async void Clicked(DropdownItem dropdownItem)
{
await OnClickEvent.InvokeAsync(label);
await OnClickEvent.InvokeAsync(dropdownItem);
}
}
}

0 comments on commit b638b2b

Please sign in to comment.