Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6226,6 +6226,12 @@
⚠️ Only available when Multiple = true.
</summary>
</member>
<member name="P:Microsoft.FluentUI.AspNetCore.Components.ListComponentBase`1.ChangeOnEnterOnly">
<summary>
Gets or sets whether using the up and down arrow keys should change focus and select immediately or that selection is done only on Enter.
⚠️ Only applicable in single select scenarios.
</summary>
</member>
<member name="P:Microsoft.FluentUI.AspNetCore.Components.ListComponentBase`1.SelectedOptionsChanged">
<summary>
Called whenever the selection changed.
Expand Down
13 changes: 12 additions & 1 deletion src/Core/Components/List/ListComponentBase.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,13 @@ protected string? InternalValue
[Parameter]
public virtual IEnumerable<TOption>? SelectedOptions { get; set; }

/// <summary>
/// Gets or sets whether using the up and down arrow keys should change focus and select immediately or that selection is done only on Enter.
/// ⚠️ Only applicable in single select scenarios.
/// </summary>
[Parameter]
public virtual bool ChangeOnEnterOnly { get; set; } = false;

/// <summary>
/// Called whenever the selection changed.
/// ⚠️ Only available when Multiple = true.
Expand Down Expand Up @@ -574,7 +581,11 @@ protected virtual async Task OnKeydownHandlerAsync(KeyboardEventArgs e)

var item = _internalListContext.Options.FirstOrDefault(i => i.Id == id);

if (item is not null)
if (item is null)
{
return;
}
if (!ChangeOnEnterOnly || (ChangeOnEnterOnly && e.Code == "Enter"))
{
await item.OnClickHandlerAsync();
}
Expand Down
Loading