Skip to content

docs(button): document IgbButton click handling syntax#249

Closed
georgianastasov wants to merge 2 commits into
masterfrom
ganastasov/igbbutton-click-handling
Closed

docs(button): document IgbButton click handling syntax#249
georgianastasov wants to merge 2 commits into
masterfrom
ganastasov/igbbutton-click-handling

Conversation

@georgianastasov
Copy link
Copy Markdown
Contributor

Closes #248

Documents the correct click-handling syntax for IgbButton.

For IgbButton, native click handlers should use the lowercase DOM-style attribute:

<IgbButton onclick="@(ResetFilters)">
    Clear filters
</IgbButton>

Instead of Blazor’s usual event directive:

<IgbButton @onclick="ResetFilters">
    Clear filters
</IgbButton>

In tested usage with IgniteUI.Blazor and Blazor WebAssembly on .NET 9, @onclick on IgbButton does not reliably fire.

The reason is specific to how the IgbButton Blazor wrapper handles unmatched attributes and forwards native DOM events to the underlying web component. The @onclick directive can be captured through the component parameter path and is not wired to the actual button click event.

Using onclick="@(Handler)" correctly wires the native click event for IgbButton.

@georgianastasov georgianastasov requested a review from Copilot May 28, 2026 09:09
@georgianastasov georgianastasov added 📖 documentation Improvements or additions to documentation ❌ status: awaiting-test PRs awaiting manual verification labels May 28, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Documents Blazor-specific click handling guidance for IgbButton, clarifying the lowercase DOM-style onclick syntax intended to address issue #248.

Changes:

  • Adds a Blazor-only “Click Event Handling” section to the Button docs.
  • Shows non-working @onclick syntax and recommended onclick="@(HandleClick)" usage.
  • Adds a note scoping the behavior to IgbButton.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


## Click Event Handling

When handling click events on `IgbButton`, use the lowercase `onclick` attribute with a Razor binding expression. Blazor's `@onclick` directive does **not** reliably fire on `IgbButton` - it is silently ignored at runtime with no compile error and no runtime warning:
Comment thread docs/xplat/src/content/en/components/inputs/button.mdx Outdated
Comment thread docs/xplat/src/content/en/components/inputs/button.mdx Outdated
@georgianastasov georgianastasov deleted the ganastasov/igbbutton-click-handling branch May 28, 2026 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

📖 documentation Improvements or additions to documentation ❌ status: awaiting-test PRs awaiting manual verification

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Blazor] Document correct click handling syntax for IgbButton in Blazor

2 participants