Skip to content

Commit 720d419

Browse files
committed
fix: Add async overloads for Input and Change methods (fixes #1795)
1 parent cd04f5d commit 720d419

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ All notable changes to **bUnit** will be documented in this file. The project ad
1111
- Added generic overloads `Find{TComponent, TElement}` and `FindAll{TComponent, TElement}` to query for specific element types (e.g., `IHtmlInputElement`). By [@linkdotnet](https://github.com/linkdotnet).
1212
- Added generic overloads `WaitForElement{TComponent, TElement}` and `WaitForElements{TComponent, TElement}` to wait for specific element types. By [@linkdotnet](https://github.com/linkdotnet).
1313

14+
### Fixed
15+
16+
- Adding convenient overloads for `InputAsync` and `ChangeAsync` to have feature parity with the sync version. Reported by [@ScarletKuro](https://github.com/ScarletKuro). Fixed by [@linkdotnet](https://github.com/linkdotnet).
17+
1418
## [2.2.2] - 2025-12-08
1519

1620
### Added

src/bunit/EventDispatchExtensions/InputEventDispatchExtensions.cs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace Bunit;
99
public static partial class EventHandlerDispatchExtensions
1010
{
1111
/// <summary>
12-
/// Raises the <c>@onchange</c> event on <paramref name="element"/>, passing the provided
12+
/// Raises the <c>@onchange</c> event on <paramref name="element"/>, passing the provided
1313
/// properties to the event handler via a <see cref="ChangeEventArgs"/> object.
1414
/// </summary>
1515
/// <param name="element">The element to raise the event on.</param>
@@ -18,14 +18,32 @@ public static void Change<T>(this IElement element, T value)
1818
=> _ = ChangeAsync(element, CreateFrom(value));
1919

2020
/// <summary>
21-
/// Raises the <c>@oninput</c> event on <paramref name="element"/>, passing the provided
21+
/// Raises the <c>@onchange</c> event on <paramref name="element"/>, passing the provided
22+
/// properties to the event handler via a <see cref="ChangeEventArgs"/> object.
23+
/// </summary>
24+
/// <param name="element">The element to raise the event on.</param>
25+
/// <param name="value">The new value.</param>
26+
public static void ChangeAsync<T>(this IElement element, T value)
27+
=> _ = ChangeAsync(element, CreateFrom(value));
28+
29+
/// <summary>
30+
/// Raises the <c>@oninput</c> event on <paramref name="element"/>, passing the provided
2231
/// properties to the event handler via a <see cref="ChangeEventArgs"/> object.
2332
/// </summary>
2433
/// <param name="element">The element to raise the event on.</param>
2534
/// <param name="value">The new value.</param>
2635
public static void Input<T>(this IElement element, T value)
2736
=> _ = InputAsync(element, CreateFrom(value));
2837

38+
/// <summary>
39+
/// Raises the <c>@oninput</c> event on <paramref name="element"/>, passing the provided
40+
/// properties to the event handler via a <see cref="ChangeEventArgs"/> object.
41+
/// </summary>
42+
/// <param name="element">The element to raise the event on.</param>
43+
/// <param name="value">The new value.</param>
44+
public static void InputAsync<T>(this IElement element, T value)
45+
=> _ = InputAsync(element, CreateFrom(value));
46+
2947
private static ChangeEventArgs CreateFrom<T>(T value) => new() { Value = FormatValue(value) };
3048

3149
private static object? FormatValue<T>(T value)

0 commit comments

Comments
 (0)