-
Notifications
You must be signed in to change notification settings - Fork 406
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add role, tabindex and simulate the Enter/Space like a Click (#2688)
- Loading branch information
Showing
16 changed files
with
400 additions
and
310 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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,61 @@ | ||
using Microsoft.AspNetCore.Components.Web; | ||
|
||
namespace Microsoft.FluentUI.AspNetCore.Components; | ||
|
||
internal static class KeyDown | ||
{ | ||
/// <summary /> | ||
public static Task SimulateClickAsync(KeyboardEventArgs e, Func<MouseEventArgs, Task> onClickAsync) | ||
{ | ||
if (e.Key == "Enter" || e.Key == " ") | ||
{ | ||
return onClickAsync.Invoke(new MouseEventArgs()); | ||
} | ||
|
||
return Task.CompletedTask; | ||
} | ||
|
||
/// <summary /> | ||
public static Task SimulateClickAsync(KeyboardEventArgs e, Func<DateTime, bool, Task> onClickAsync, DateTime value, bool dayDisabled) | ||
{ | ||
if (e.Key == "Enter" || e.Key == " ") | ||
{ | ||
return onClickAsync.Invoke(value, dayDisabled); | ||
} | ||
|
||
return Task.CompletedTask; | ||
} | ||
|
||
/// <summary /> | ||
public static Task SimulateClickAsync(KeyboardEventArgs e, Func<CalendarTitles, Task> onClickAsync, CalendarTitles title) | ||
{ | ||
if (e.Key == "Enter" || e.Key == " ") | ||
{ | ||
return onClickAsync.Invoke(title); | ||
} | ||
|
||
return Task.CompletedTask; | ||
} | ||
|
||
/// <summary /> | ||
public static Task SimulateClickAsync(KeyboardEventArgs e, Func<int, int, bool, Task> onClickAsync, int year, int month, bool isReadOnly) | ||
{ | ||
if (e.Key == "Enter" || e.Key == " ") | ||
{ | ||
return onClickAsync.Invoke(year, month, isReadOnly); | ||
} | ||
|
||
return Task.CompletedTask; | ||
} | ||
|
||
/// <summary /> | ||
public static Task SimulateClickAsync(KeyboardEventArgs e, Func<int, bool, Task> onClickAsync, int year, bool isReadOnly) | ||
{ | ||
if (e.Key == "Enter" || e.Key == " ") | ||
{ | ||
return onClickAsync.Invoke(year, isReadOnly); | ||
} | ||
|
||
return Task.CompletedTask; | ||
} | ||
} |
Oops, something went wrong.