mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2026-08-11 02:21:16 +10:00
fix: apply imported config selections to lazily-built tabs (#4938)
Tabs other than Install build their checkboxes lazily on first visit. Import populates $sync.selected* and calls Reset-WPFCheckBoxes, but that only touches checkboxes that already exist in $sync, so any tab not yet visited gets its controls built later with default (unchecked) state and never reflects the import. Re-apply Reset-WPFCheckBoxes right after a tab's controls are built so it picks up existing selections.
This commit is contained in:
@@ -36,4 +36,7 @@ function Initialize-WinUtilTabContent {
|
||||
}
|
||||
|
||||
$sync.InitializedTabs[$TabName] = $true
|
||||
|
||||
# Sync freshly built controls to any selections already in $sync.selected* (import/preset).
|
||||
Reset-WPFCheckBoxes -doToggles $true
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ BeforeAll {
|
||||
param([string]$TargetGridName)
|
||||
}
|
||||
function Invoke-WinUtilISOCheckExistingWork { }
|
||||
function Reset-WPFCheckBoxes { param([bool]$doToggles) }
|
||||
|
||||
. (Join-Path $script:repoRoot "functions\private\Initialize-WinUtilTabContent.ps1")
|
||||
}
|
||||
@@ -29,6 +30,7 @@ Describe "Initialize-WinUtilTabContent" {
|
||||
|
||||
Mock Invoke-WPFUIElements { }
|
||||
Mock Initialize-WPFUI { }
|
||||
Mock Reset-WPFCheckBoxes { }
|
||||
}
|
||||
|
||||
AfterEach {
|
||||
@@ -51,6 +53,21 @@ Describe "Initialize-WinUtilTabContent" {
|
||||
$script:sync.InitializedTabs["Install"] | Should -BeTrue
|
||||
}
|
||||
|
||||
It "re-applies checkbox selections after building a tab's controls" {
|
||||
Initialize-WinUtilTabContent -TabName "Tweaks"
|
||||
|
||||
Should -Invoke -CommandName Reset-WPFCheckBoxes -Times 1 -Exactly -ParameterFilter {
|
||||
$doToggles -eq $true
|
||||
}
|
||||
}
|
||||
|
||||
It "does not re-apply checkbox selections on a tab that's already built" {
|
||||
Initialize-WinUtilTabContent -TabName "Tweaks"
|
||||
Initialize-WinUtilTabContent -TabName "Tweaks"
|
||||
|
||||
Should -Invoke -CommandName Reset-WPFCheckBoxes -Times 1 -Exactly
|
||||
}
|
||||
|
||||
It "initializes deferred config-backed tabs once" {
|
||||
Initialize-WinUtilTabContent -TabName "Tweaks"
|
||||
Initialize-WinUtilTabContent -TabName "Config"
|
||||
|
||||
Reference in New Issue
Block a user