Turn the Install category filters into toggle chips (#4926)

* Turn the Install category filters into toggle chips

- Replace the filter buttons with toggles that show which ones are active
- Add ctrl click to select more than one category
- Keep the search box and the category filter independent of each other
- Expand matching categories while a filter is active

* Fix the filter interactions the category chips missed

- Pass the selected categories to the lazy rendering batches, the old call
  used a parameter that no longer exists and threw while typing
- Keep the category filter when switching tabs, the chips stayed checked
  while the filter itself was dropped
- Put a category back to collapsed once the filter that expanded it is gone

* Document the Install category filters

- Add a guide section for the chips, ctrl click and clearing the filter
- Note that search and the category chips apply together

* Correct the category filter guide wording

- Clearing by clicking the chip only applies when it is the only one selected
- Only categories with matches expand, and only auto expanded ones re-collapse
This commit is contained in:
MyDrift
2026-08-09 13:13:21 -05:00
committed by GitHub
parent 9fdadd1c8f
commit 32ab9f0ab0
13 changed files with 311 additions and 80 deletions
+3 -1
View File
@@ -21,7 +21,9 @@ Describe "Install app rendering startup contract" {
$renderScript | Should -Match 'Dispatcher\.BeginInvoke'
$renderScript | Should -Match 'Invoke-WinUtilInstallAppRenderNextBatch'
$renderScript | Should -Match 'Initialize-InstallAppEntry'
$renderScript | Should -Match 'Find-AppsByNameOrDescription -SearchString \$sync\.SearchBar\.Text -Category \$sync\.SearchBar\.Tag'
$renderScript | Should -Match 'Find-AppsByNameOrDescription -SearchString \$sync\.SearchBar\.Text -Categories \$selectedCategories'
# A batch has to be filtered when either filter is on, not only when there is search text
$renderScript | Should -Match '\$selectedCategories\.Count -gt 0'
$renderScript | Should -Match '\$sync\.InstallAppEntriesRendered = \$true'
}
+75 -1
View File
@@ -379,12 +379,86 @@ Describe "Find-AppsByNameOrDescription" {
$category = New-WinUtilAppCategory -Label "- Tools" -Items @($utilityItem, $powerToysItem)
New-WinUtilAppSearchContext -Categories @($category)
Find-AppsByNameOrDescription -SearchString "Utilities" -Category "Utilities"
Find-AppsByNameOrDescription -Categories @("Utilities")
$utilityItem.Visibility | Should -Be ([Windows.Visibility]::Visible)
$powerToysItem.Visibility | Should -Be ([Windows.Visibility]::Collapsed)
$category.Visibility | Should -Be ([Windows.Visibility]::Visible)
}
It "shows apps from every selected category when several chips are active" {
$utilityItem = New-WinUtilAppSearchItem -Tag "WPFInstallLiteral"
$powerToysItem = New-WinUtilAppSearchItem -Tag "WPFInstallPowerToys"
$browserItem = New-WinUtilAppSearchItem -Tag "WPFInstallBrowser"
$category = New-WinUtilAppCategory -Label "- Tools" -Items @($utilityItem, $powerToysItem, $browserItem)
New-WinUtilAppSearchContext -Categories @($category)
Find-AppsByNameOrDescription -Categories @("Utilities", "Microsoft Tools")
$utilityItem.Visibility | Should -Be ([Windows.Visibility]::Visible)
$powerToysItem.Visibility | Should -Be ([Windows.Visibility]::Visible)
$browserItem.Visibility | Should -Be ([Windows.Visibility]::Collapsed)
}
It "applies the search text and the category filter together" {
$powerToysItem = New-WinUtilAppSearchItem -Tag "WPFInstallPowerToys"
$literalItem = New-WinUtilAppSearchItem -Tag "WPFInstallLiteral"
$category = New-WinUtilAppCategory -Label "- Tools" -Items @($powerToysItem, $literalItem)
New-WinUtilAppSearchContext -Categories @($category)
Find-AppsByNameOrDescription -SearchString "PowerToys" -Categories @("Microsoft Tools")
$powerToysItem.Visibility | Should -Be ([Windows.Visibility]::Visible)
$literalItem.Visibility | Should -Be ([Windows.Visibility]::Collapsed)
}
It "hides a category when the search text matches nothing inside the selected categories" {
$powerToysItem = New-WinUtilAppSearchItem -Tag "WPFInstallPowerToys"
$category = New-WinUtilAppCategory -Label "- Tools" -Items @($powerToysItem)
New-WinUtilAppSearchContext -Categories @($category)
Find-AppsByNameOrDescription -SearchString "Firefox" -Categories @("Microsoft Tools")
$powerToysItem.Visibility | Should -Be ([Windows.Visibility]::Collapsed)
$category.Visibility | Should -Be ([Windows.Visibility]::Collapsed)
}
It "expands a collapsed category that has matches for the selected filter" {
$powerToysItem = New-WinUtilAppSearchItem -Tag "WPFInstallPowerToys"
$category = New-WinUtilAppCategory -Label "+ Tools" -Items @($powerToysItem)
New-WinUtilAppSearchContext -Categories @($category)
Find-AppsByNameOrDescription -Categories @("Microsoft Tools")
$category.Children[0].Content | Should -Be "- Tools"
$category.Children[1].Visibility | Should -Be ([Windows.Visibility]::Visible)
}
It "re-collapses a category it expanded once the filter is cleared" {
$powerToysItem = New-WinUtilAppSearchItem -Tag "WPFInstallPowerToys"
$category = New-WinUtilAppCategory -Label "+ Tools" -Items @($powerToysItem)
New-WinUtilAppSearchContext -Categories @($category)
Find-AppsByNameOrDescription -Categories @("Microsoft Tools")
$category.Children[0].Content | Should -Be "- Tools"
Find-AppsByNameOrDescription -SearchString ""
$category.Children[0].Content | Should -Be "+ Tools"
$category.Children[1].Visibility | Should -Be ([Windows.Visibility]::Collapsed)
}
It "leaves a category the user had expanded alone when the filter is cleared" {
$powerToysItem = New-WinUtilAppSearchItem -Tag "WPFInstallPowerToys"
$category = New-WinUtilAppCategory -Label "- Tools" -Items @($powerToysItem)
New-WinUtilAppSearchContext -Categories @($category)
Find-AppsByNameOrDescription -Categories @("Microsoft Tools")
Find-AppsByNameOrDescription -SearchString ""
$category.Children[0].Content | Should -Be "- Tools"
$category.Children[1].Visibility | Should -Be ([Windows.Visibility]::Visible)
}
}
Describe "Find-TweaksByNameOrDescription" {
+6 -2
View File
@@ -182,7 +182,8 @@ Describe "XAML document" {
It "wires the Document search chip to an existing Document category" {
$mainScript = Get-Content -Path $script:mainScriptPath -Raw
$mainScript | Should -Match '\$sync\["WPFSearchChipDocument"\]\.Add_Click\(\{ Set-WinUtilAppCategoryFilter -Category "Document" \}\)'
$mainScript | Should -Match '@\{ Name = "WPFSearchChipDocument";\s+Category = "Document" \}'
$mainScript | Should -Match '\$sync\["WPFSearchChipDocument"\]\.Add_Click\(\{ Invoke-WinUtilAppCategoryChip -Chip \$this \}\)'
$applications = Get-WinUtilConfigObject -Name "applications"
$categories = @($applications.PSObject.Properties | ForEach-Object { $_.Value.category } | Sort-Object -Unique)
@@ -468,7 +469,10 @@ Describe "XAML and sync wiring" {
"Win11ISOProcessRunning",
"Win11ISOWorkDir",
"Win11ISOContentsDir",
"Win11ISOUSBDisks"
"Win11ISOUSBDisks",
"AppCategoryChips",
"SelectedAppCategories",
"AppCategoryAutoExpanded"
)
$allowedNames = @($xamlNames + $generatedNames + $dynamicStateNames) | Sort-Object -Unique
$bracketReferences = @(