-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathDropdownInitializer.razor.cs
48 lines (37 loc) · 1.36 KB
/
DropdownInitializer.razor.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using Microsoft.AspNetCore.Components;
using Fluxor;
using Fluxor.Blazor.Web.Components;
using Luthetus.Common.RazorLib.Dropdowns.Models;
using Luthetus.Common.RazorLib.Dropdowns.States;
using Luthetus.Common.RazorLib.Contexts.Displays;
namespace Luthetus.Common.RazorLib.Dropdowns.Displays;
public partial class DropdownInitializer : FluxorComponent
{
[Inject]
private IState<DropdownState> DropdownStateWrap { get; set; } = null!;
[Inject]
private IDispatcher Dispatcher { get; set; } = null!;
private ContextBoundary? _dropdownContextBoundary;
private async Task ClearActiveKeyList()
{
var firstDropdown = DropdownStateWrap.Value.DropdownList.FirstOrDefault();
if (firstDropdown is not null)
{
var restoreFocusOnCloseFunc = firstDropdown.RestoreFocusOnClose;
if (restoreFocusOnCloseFunc is not null)
await restoreFocusOnCloseFunc.Invoke();
}
Dispatcher.Dispatch(new DropdownState.ClearAction());
}
private Task HandleOnFocusIn(DropdownRecord dropdown)
{
var localDropdownContextBoundary = _dropdownContextBoundary;
if (localDropdownContextBoundary is not null)
localDropdownContextBoundary.HandleOnFocusIn();
return Task.CompletedTask;
}
private Task HandleOnFocusOut(DropdownRecord dropdown)
{
return Task.CompletedTask;
}
}