-
Notifications
You must be signed in to change notification settings - Fork 43
Closed
Labels
bugSomething isn't workingSomething isn't working
Milestone
Description
Description
In the ValueChanged callback of a Select component, I call FocusAsync on the FocusManager with the key set on another Select component. The 2nd Select component doesn't receive focus at this moment.
Upon debugging the FocusManager, it seems that the FocusTarget not only doesn't exist but also, when given some delay to allow the rendering to complete, the @key isn't correctly applied as its FocusTarget's Key.
Steps to Reproduce
Run an application with the follow code:
@using RazorConsole.Components
@using RazorConsole.Core.Focus
@inject FocusManager FocusManager
<Rows>
@* First level of menu *@
<Select TItem="string"
Options="@_mainCategories"
Value="@_selectedCategory"
ValueChanged="@OnMainCategoryChanged">
</Select>
@* Second level of menu that appears after selection *@
@if (_selectedCategory != null)
{
<Select TItem="string"
@Key="test"
Options="@_subCategories"
ValueChanged="OnSubCategoryChanged">
</Select>
}
</Rows>
@code {
private static string test = "test";
private string[] _mainCategories = { "Settings", "Game", "Exit" };
private string[] _subCategories = { "Sound", "Video", "Keyboard" };
private string? _selectedCategory;
private async Task OnMainCategoryChanged(string value)
{
_selectedCategory = value;
StateHasChanged();
await Task.Delay(1000);
// Move focus to next element
await FocusManager.FocusAsync(test);
}
private void OnSubCategoryChanged(string value)
{
// etc
}
}
Observe that the Select containing the options (Sound, Video, and Keyboard) does not receive focus.
Expected Behavior
Upon Selecting an option in the first select component, the 2nd Select gets focus.
Actual Behavior
The focus remains unchanged.
Environment
- RazorConsole version: Tried 0.4.0 and 0.5.0-alpha
- .NET version: net9.0
- Windows 10 Pro
- Terminal: Jetbrains Rider Integrated Terminal
Additional Context
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working