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
@@ -1,4 +1,4 @@
@inject DataSource Data
@inject DataSource Data

<FluentAutocomplete Id="my-customized"
@ref="ContactList"
Expand All @@ -7,7 +7,7 @@
Placeholder="search"
OnOptionsSearch="@OnSearch"
MaximumSelectedOptions="3"
OptionText="@(item => item.LastName)"
OptionText="@(item => item.FirstName)"
OptionStyle="min-height: 40px;"
@bind-SelectedOptions="@SelectedItems">

Expand Down
18 changes: 12 additions & 6 deletions src/Core/Components/List/FluentAutocomplete.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ await InputHandlerAsync(new ChangeEventArgs()
}

// ArrowUp
Task KeyDown_ArrowUpAsync()
async Task KeyDown_ArrowUpAsync()
{
if (Items != null && Items.Any())
{
Expand All @@ -423,13 +423,16 @@ Task KeyDown_ArrowUpAsync()
break;
}
}
}

return Task.CompletedTask;
if (Module != null)
{
await Module.InvokeVoidAsync("scrollToFirstSelectable", IdPopup, false);
}
}
}

// ArrowDown
Task KeyDown_ArrowDownAsync()
async Task KeyDown_ArrowDownAsync()
{
if (Items != null && Items.Any())
{
Expand All @@ -447,9 +450,12 @@ Task KeyDown_ArrowDownAsync()
break;
}
}
}

return Task.CompletedTask;
if (Module != null)
{
await Module.InvokeVoidAsync("scrollToFirstSelectable", IdPopup, true);
}
}
}

// Enter
Expand Down
12 changes: 12 additions & 0 deletions src/Core/Components/List/FluentAutocomplete.razor.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@ export function displayLastSelectedItem(id) {
}
}

export function scrollToFirstSelectable(idPopup, goDown) {

const popup = document.getElementById(idPopup);
const item = popup?.querySelector("fluent-option[selectable]")
const next = goDown ? item?.nextElementSibling : item?.previousElementSibling;

if (!!next) {
next.scrollIntoView({ behavior: 'smooth', block: 'nearest', inline: 'start' });
}

}

export function focusOn(id) {
var item = document.getElementById(id);
if (!!item) {
Expand Down