Skip to content

Commit 408799b

Browse files
committed
feat: search input focus
1 parent cba494a commit 408799b

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

TelegramDownloader/Shared/MobileFileManager/MobileFileManager.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
9090
<circle cx="11" cy="11" r="8"/><path d="m21 21-4.35-4.35"/>
9191
</svg>
92-
<input type="text" placeholder="Search files..." @bind="SearchText" @bind:event="oninput" @onkeyup="OnSearchKeyUp" />
92+
<input type="text" placeholder="Search files..." @bind="SearchText" @bind:event="oninput" @onkeyup="OnSearchKeyUp" @ref="searchInput" />
9393
@if (!string.IsNullOrEmpty(SearchText))
9494
{
9595
<button class="mfm-btn-icon-sm" @onclick="ClearSearchText" title="Clear text">

TelegramDownloader/Shared/MobileFileManager/MobileFileManager.razor.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ private List<FileManagerDirectoryContent> DisplayFiles
176176
private string NewFolderName { get; set; } = string.Empty;
177177
private ElementReference newFolderInput;
178178

179+
private ElementReference searchInput;
180+
179181
private bool ShowDetailsPanel { get; set; } = false;
180182
private FileManagerDirectoryContent? DetailsItem { get; set; }
181183

@@ -1018,7 +1020,7 @@ private bool IsAudioFile(FileManagerDirectoryContent file)
10181020

10191021
#region Search
10201022

1021-
private void ToggleSearch()
1023+
private async Task ToggleSearch()
10221024
{
10231025
ShowSearch = !ShowSearch;
10241026
ShowMoreMenu = false;
@@ -1027,6 +1029,17 @@ private void ToggleSearch()
10271029
SearchText = string.Empty;
10281030
}
10291031
StateHasChanged();
1032+
1033+
// Focus on search input after showing
1034+
if (ShowSearch)
1035+
{
1036+
await Task.Delay(50); // Small delay to ensure the input is rendered
1037+
try
1038+
{
1039+
await searchInput.FocusAsync();
1040+
}
1041+
catch { /* Input may not be rendered yet */ }
1042+
}
10301043
}
10311044

10321045
private async Task OnSearchKeyUp(KeyboardEventArgs e)

0 commit comments

Comments
 (0)