Skip to content
Merged
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 @@ -162,7 +162,12 @@ private async Task OnInputHandler()
_skipInputEvent = false;
return;
}
await FocusNext();

var current = _elementReferences[_lastFocusedIndex];
var val = current.GetState(x => x.Value)?.ToString();

if (!string.IsNullOrEmpty(val))
await FocusNext();
}

/// <summary>
Expand All @@ -173,36 +178,49 @@ private async Task OnInputHandler()
protected async Task HandleKeyDown(KeyboardEventArgs arg)
{
if (Disabled || ReadOnly)
{
return;
}

if (arg.Key == "Backspace" || arg.Key == "ArrowLeft" || arg.Key == "Delete")
if (arg.Key == "Backspace")
{
_skipInputEvent = true;
_skipRefocus = true;
if (arg.Key == "Delete")
var current = _elementReferences[_lastFocusedIndex];
var currentValue = current.GetState(x => x.Value)?.ToString();

if (!string.IsNullOrEmpty(currentValue))
{
await _elementReferences[_lastFocusedIndex].Clear();
_skipInputEvent = true;
await current.Clear();
_skipInputEvent = false;
return;
}

_skipRefocus = true;

if (RuntimeLocation.IsClientSide)
{
await Task.Delay(10);
}

await FocusPrevious();
return;
}

if (arg.Key == "Delete")
{
_skipInputEvent = true;
await _elementReferences[_lastFocusedIndex].Clear();
_skipInputEvent = false;
return;
}

if (arg.Key == "ArrowLeft")
{
await FocusPrevious();
return;
}

if (arg.Key == "ArrowRight")
{
if (RuntimeLocation.IsClientSide)
{
await Task.Delay(10);
}
await FocusNext();
return;
}

}

private int _lastFocusedIndex = 0;
Expand Down
Loading