Skip to content

Commit

Permalink
adjust focus back to Dev Home control after File Explorer is closed (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ssparach authored Oct 7, 2024
1 parent 93ab5ad commit 8a43c92
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
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;
_log.Debug($"AddRepositoryCard IsEnabled: {addRepositoryCard.IsEnabled}");
_log.Debug($"AddRepositoryCard Visibility: {addRepositoryCard.Visibility}");
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

0 comments on commit 8a43c92

Please sign in to comment.