Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Dev Home]: Keyboard focus goes missing on closing 'Select Folder' window using keyboard #3926

Merged
merged 1 commit into from
Oct 7, 2024
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
Expand Up @@ -2,12 +2,12 @@
// Licensed under the MIT License.

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Threading.Tasks;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using CommunityToolkit.WinUI.Controls;
using DevHome.Common.Contracts;
using DevHome.Common.Extensions;
using DevHome.Common.Models;
Expand Down Expand Up @@ -158,7 +158,7 @@ public bool ShowRepositoryStatus
}

[RelayCommand]
public async Task<string> AddFolderClick()
public async Task<string> AddFolderClick(object sender)
{
StorageFolder? repoRootFolder = null;
if (IsFeatureEnabled)
Expand Down Expand Up @@ -187,6 +187,7 @@ await Task.Run(async () =>
}
});
RefreshTrackedRepositories();
AdjustFocus(sender);
}

return repoRootFolder == null ? string.Empty : repoRootFolder.Path;
Expand Down Expand Up @@ -292,4 +293,17 @@ public async void OnToggledRepositoryStatusSettingAsync(bool value)

await LocalSettingsService!.SaveSettingAsync("ShowRepositoryStatus", value);
}

private void AdjustFocus(object sender)
{
var addRepositoryCard = sender as SettingsCard;
if (addRepositoryCard != null)
{
addRepositoryCard.IsTabStop = true;
ssparach marked this conversation as resolved.
Show resolved Hide resolved
_log.Debug($"AddRepositoryCard IsEnabled: {addRepositoryCard.IsEnabled}");
_log.Debug($"AddRepositoryCard Visibility: {addRepositoryCard.Visibility}");
ssparach marked this conversation as resolved.
Show resolved Hide resolved
bool isFocusSet = addRepositoryCard.Focus(FocusState.Keyboard);
_log.Information($"Set focus to add reposiotry card result: {isFocusSet}");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
Style="{StaticResource SettingsSectionHeaderTextBlockStyle}"/>
<ctControls:SettingsCard
x:Uid="AddRepositoriesCard"
x:Name="AddRepositoriesCard"
Grid.Column="1">
<Button
x:Uid="AddFolderButton"
Style="{ThemeResource AccentButtonStyle}"
Command="{x:Bind ViewModel.AddFolderClickCommand}" />
Command="{x:Bind ViewModel.AddFolderClickCommand}"
CommandParameter="{Binding ElementName=AddRepositoriesCard}"/>
</ctControls:SettingsCard>
<ItemsRepeater
Name="ItemsRepeaterForAllRepoPaths"
Expand Down
Loading