diff --git a/pester/xaml.Tests.ps1 b/pester/xaml.Tests.ps1 index 887fe28c..5b07c562 100644 --- a/pester/xaml.Tests.ps1 +++ b/pester/xaml.Tests.ps1 @@ -135,6 +135,7 @@ Describe "XAML document" { "WPFTab4BT", "WPFTab5BT", "SearchBar", + "SearchBarIcon", "SearchBarClearButton", "appscategory", "appspanel", @@ -271,6 +272,32 @@ Describe "XAML document" { } } + It "keeps the responsive search controls within the available screen width" { + $window = $script:xaml.DocumentElement + $searchBar = $script:xaml.SelectSingleNode('//*[local-name()="TextBox"][@Name="SearchBar"]') + $searchBorder = $searchBar.ParentNode.ParentNode + $mainScript = Get-Content -Path $script:mainScriptPath -Raw + + $window.GetAttribute("MinWidth") | Should -Be "800" + $searchBorder.GetAttribute("Width") | Should -BeNullOrEmpty + $searchBorder.GetAttribute("HorizontalAlignment") | Should -Be "Stretch" + $searchBar.GetAttribute("Width") | Should -BeNullOrEmpty + $searchBar.GetAttribute("HorizontalAlignment") | Should -Be "Stretch" + $mainScript | Should -Match '\$sync\.Form\.MinWidth = "1150"' + $mainScript | Should -Match '\$sync\.Form\.MinWidth = \[Math\]::Min\(\[double\]\$sync\.Form\.MinWidth, \[double\]\$screenWidth\)' + } + + It "shows only one search action glyph at a time" { + $searchIcon = $script:xaml.SelectSingleNode('//*[local-name()="TextBlock"][@Name="SearchBarIcon"]') + $clearButton = $script:xaml.SelectSingleNode('//*[local-name()="Button"][@Name="SearchBarClearButton"]') + $mainScript = Get-Content -Path $script:mainScriptPath -Raw + + $searchIcon | Should -Not -BeNullOrEmpty + $clearButton | Should -Not -BeNullOrEmpty + $mainScript | Should -Match '\$sync\.SearchBarClearButton\.Visibility = "Visible"\s+\$sync\.SearchBarIcon\.Visibility = "Collapsed"' + $mainScript | Should -Match '\$sync\.SearchBarClearButton\.Visibility = "Collapsed"\s+\$sync\.SearchBarIcon\.Visibility = "Visible"' + } + It "scopes toggle button styles without leaking into combo boxes" { $resources = $script:xaml.SelectSingleNode('//*[local-name()="Window.Resources"]') $implicitToggleStyles = @($resources.SelectNodes('./*[local-name()="Style"][@TargetType="ToggleButton" or @TargetType="{x:Type ToggleButton}"][not(@x:Key)]', $script:xamlNamespace)) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index 8fbeb08a..90ba5a73 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -285,6 +285,7 @@ $sync["Form"].Add_ContentRendered({ # Extract screen width and height for the primary monitor $screenWidth = $primaryScreen.Bounds.Width $screenHeight = $primaryScreen.Bounds.Height + $sync.Form.MinWidth = [Math]::Min([double]$sync.Form.MinWidth, [double]$screenWidth) # Compare with the primary monitor size if ($sync.Form.ActualWidth -gt $screenWidth -or $sync.Form.ActualHeight -gt $screenHeight) { @@ -353,8 +354,10 @@ $searchBarTimer.add_Tick({ $sync["SearchBar"].Add_TextChanged({ if ($sync.SearchBar.Text -ne "") { $sync.SearchBarClearButton.Visibility = "Visible" + $sync.SearchBarIcon.Visibility = "Collapsed" } else { $sync.SearchBarClearButton.Visibility = "Collapsed" + $sync.SearchBarIcon.Visibility = "Visible" } if ($searchBarTimer.IsEnabled) { $searchBarTimer.Stop() @@ -365,7 +368,7 @@ $sync["SearchBar"].Add_TextChanged({ $sync["Form"].Add_Loaded({ param($e) $null = $e - $sync.Form.MinWidth = "1000" + $sync.Form.MinWidth = "1150" $sync["Form"].MaxWidth = [Double]::PositiveInfinity $sync["Form"].MaxHeight = [Double]::PositiveInfinity }) diff --git a/xaml/inputXML.xaml b/xaml/inputXML.xaml index 0e83dfd0..50a2326e 100644 --- a/xaml/inputXML.xaml +++ b/xaml/inputXML.xaml @@ -1039,13 +1039,12 @@ - +