CmdPal: Hide search box on content pages [experiment] (#41479)

## Summary of the Pull Request

CmdPal now displays the search box only on pages that derive from
ListPage. On ContentPage (forms, etc.), the search box is hidden.

- Moves keyboard shortcut handling from SearchBox to ShellPage so
shortcuts are always handled.
- Keeps the search box hidden/disabled to preserve layout metrics. 
- Refines focus management to prevent focus jumps during navigation. 
- For ContentPage page's content gains focus automatically (not just
form inputs, but now markdown content as well - so you can scroll
immediately, for example).
- Adds accessibility (a11y) tweaks: when navigating to content pages
without a visible search box, sets an explicit focus target so screen
readers announce a meaningful element. Screen reader will now announce
navigation to the page.
- Adds a title to the main list page - "Home".


https://github.com/user-attachments/assets/f60d0826-df1f-468e-8e41-0266cd27878b


<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [x] Closes: #38967
- [ ] **Communication:** I've discussed this with core contributors
already. If the work hasn't been agreed, this work might be rejected
- [ ] **Tests:** Added/updated and all pass
- [ ] **Localization:** All end-user-facing strings can be localized
- [ ] **Dev docs:** Added/updated
- [ ] **New binaries:** Added on the required places
- [ ] [JSON for
signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [ ] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx

<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
This commit is contained in:
Jiří Polášek
2025-09-26 23:00:53 +02:00
committed by GitHub
parent e1681ec08f
commit 2b6c5d2cdd
11 changed files with 204 additions and 54 deletions

View File

@@ -9,6 +9,7 @@
xmlns:coreViewModels="using:Microsoft.CmdPal.Core.ViewModels"
xmlns:cpcontrols="using:Microsoft.CmdPal.UI.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:h="using:Microsoft.CmdPal.UI.Helpers"
xmlns:help="using:Microsoft.CmdPal.UI.Helpers"
xmlns:labToolkit="using:CommunityToolkit.Labs.WinUI.MarkdownTextBlock"
xmlns:markdownImageProviders="using:Microsoft.CmdPal.UI.Helpers.MarkdownImageProviders"
@@ -16,7 +17,6 @@
xmlns:tkcontrols="using:CommunityToolkit.WinUI.Controls"
xmlns:toolkit="using:CommunityToolkit.WinUI.Controls"
xmlns:ui="using:CommunityToolkit.WinUI"
xmlns:viewModels="using:Microsoft.CmdPal.UI.ViewModels"
Background="Transparent"
mc:Ignorable="d">
@@ -27,8 +27,6 @@
EmptyValue="Collapsed"
NotEmptyValue="Visible" />
<converters:BoolNegationConverter x:Key="BoolNegationConverter" />
<cmdpalUI:MessageStateToSeverityConverter x:Key="MessageStateToSeverityConverter" />
<cmdpalUI:DetailsDataTemplateSelector
@@ -175,9 +173,12 @@
<!-- Back button and search box -->
<Grid
x:Name="TopBarGrid"
Padding="0,12,0,12"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch">
VerticalAlignment="Stretch"
BorderBrush="{ThemeResource DividerStrokeColorDefaultBrush}"
BorderThickness="0,0,0,1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
@@ -354,11 +355,7 @@
</animations:Implicit.HideAnimations>
</ProgressBar>
<Grid
x:Name="ContentGrid"
Grid.Row="1"
BorderBrush="{ThemeResource DividerStrokeColorDefaultBrush}"
BorderThickness="0,1,0,1">
<Grid x:Name="ContentGrid" Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="3*" />
@@ -367,6 +364,9 @@
<Frame
Name="RootFrame"
AutomationProperties.AutomationControlType="Pane"
AutomationProperties.LandmarkType="Navigation"
AutomationProperties.LiveSetting="Assertive"
IsNavigationStackEnabled="True"
Navigated="RootFrame_Navigated" />
@@ -502,7 +502,11 @@
</InfoBar>
</StackPanel>
<Grid Grid.Row="1" Background="{ThemeResource LayerOnAcrylicSecondaryBackgroundBrush}">
<Grid
Grid.Row="1"
Background="{ThemeResource LayerOnAcrylicSecondaryBackgroundBrush}"
BorderBrush="{ThemeResource DividerStrokeColorDefaultBrush}"
BorderThickness="0,1,0,0">
<cpcontrols:CommandBar CurrentPageViewModel="{x:Bind ViewModel.CurrentPage, Mode=OneWay}" />
</Grid>
@@ -519,6 +523,26 @@
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
<VisualStateGroup>
<!--
Why disable it and make it transparent?
To prevent the container from collapsing, ensuring the layout metrics remain unchanged.
-->
<VisualStateGroup.Transitions>
<VisualTransition GeneratedDuration="0:0:0.187" To="SearchBarCollapsed" />
</VisualStateGroup.Transitions>
<VisualState x:Name="SearchBarVisible" />
<VisualState x:Name="SearchBarCollapsed">
<VisualState.StateTriggers>
<StateTrigger IsActive="{x:Bind h:BindTransformers.Negate(ViewModel.IsSearchBoxVisible), Mode=OneWay}" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="SearchBox.IsEnabled" Value="False" />
<Setter Target="SearchBox.Opacity" Value="0" />
<Setter Target="TopBarGrid.BorderBrush" Value="Transparent" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid>
</Page>