From f4a281238088038ddfb7eef8b56d624b060f386f Mon Sep 17 00:00:00 2001 From: almedina-ms <35784165+almedina-ms@users.noreply.github.com> Date: Fri, 9 Apr 2021 15:10:34 -0700 Subject: [PATCH] [BreadcrumbBar] Add theme resource keys for customizing Chevron padding and font weight (#4727) * Add styles for dropdown flyout * Fix ellipsis flyout widht * Fix margins for breadcrumb items * Remove flyout style retrieval and set it directly in xaml file * First version of margin modification * Fix margin bottom * Fix focus margin height and fix padding for last item * Stretch border for inline items and compress for dropdown items * Fix PR comments * Readd corner radius * Add modifiable padding between chevrons * Fix missing resource key * Fix margin and padding * Remove padding resource key for a different PR * Move resources to theme resources * Add test to verify current item doesnt raise invoke pattern and fix tests * Remove extra keys * Move margins to be rendered close to the buttons * Add resource keys for font weight and chevron padding * Clean xaml a little bit * Remove other unused keys * Hide element from Accessibility tree * Remove hard coded breadcrumb names * Fix accessibility control type and name * Removed unused properties * Remove extra code lines and set button to non focusable * Remove hard coded naming for drop down items * Fix comments from PR * Remove unnecesary automation strings * Fix tests * small refactor to DropDown item retrieval method * Fix DropDown item margin * Remove extra theme resources keys * Fix comments from design review * Last fixes from focus rect --- dev/Breadcrumb/BreadcrumbBar.cpp | 5 - dev/Breadcrumb/BreadcrumbBar.h | 3 - dev/Breadcrumb/BreadcrumbBar.xaml | 162 +++++++++++------- dev/Breadcrumb/BreadcrumbBarItem.cpp | 3 - dev/Breadcrumb/BreadcrumbBarItem.h | 1 - .../BreadcrumbBarItemAutomationPeer.cpp | 6 + .../BreadcrumbBarItemAutomationPeer.h | 1 + .../BreadcrumbBar_themeresources.xaml | 36 ++-- .../InteractionTests/BreadcrumbBarTests.cs | 113 ++++++++---- dev/Breadcrumb/Strings/en-us/Resources.resw | 4 + dev/ResourceHelper/ResourceAccessor.h | 1 + 11 files changed, 218 insertions(+), 117 deletions(-) diff --git a/dev/Breadcrumb/BreadcrumbBar.cpp b/dev/Breadcrumb/BreadcrumbBar.cpp index 31a2a9a9ad..02463e2910 100644 --- a/dev/Breadcrumb/BreadcrumbBar.cpp +++ b/dev/Breadcrumb/BreadcrumbBar.cpp @@ -257,8 +257,6 @@ void BreadcrumbBar::OnElementPreparedEvent(const winrt::ItemsRepeater&, const wi // Any other element just resets the visual properties itemImpl->ResetVisualProperties(); } - - winrt::AutomationProperties::SetName(item, s_breadcrumbItemAutomationName + winrt::to_hstring(itemIndex)); } } } @@ -280,7 +278,6 @@ void BreadcrumbBar::OnElementIndexChangedEvent(const winrt::ItemsRepeater& sende } FocusElementAt(newIndex); - winrt::AutomationProperties::SetName(args.Element(), s_breadcrumbItemAutomationName + winrt::to_hstring(newIndex)); } } @@ -290,8 +287,6 @@ void BreadcrumbBar::OnElementClearingEvent(const winrt::ItemsRepeater&, const wi { const auto& itemImpl = winrt::get_self(item); itemImpl->ResetVisualProperties(); - - winrt::AutomationProperties::SetName(item, winrt::hstring()); } } diff --git a/dev/Breadcrumb/BreadcrumbBar.h b/dev/Breadcrumb/BreadcrumbBar.h index fcce99b5a8..561809d26a 100644 --- a/dev/Breadcrumb/BreadcrumbBar.h +++ b/dev/Breadcrumb/BreadcrumbBar.h @@ -96,7 +96,4 @@ class BreadcrumbBar : // Template Parts static constexpr std::wstring_view s_itemsRepeaterPartName{ L"PART_ItemsRepeater"sv }; - - // Automation Names - static constexpr std::wstring_view s_breadcrumbItemAutomationName{ L"BreadcrumbBarItem"sv }; }; diff --git a/dev/Breadcrumb/BreadcrumbBar.xaml b/dev/Breadcrumb/BreadcrumbBar.xaml index 6f00cf33a0..3b87367f27 100644 --- a/dev/Breadcrumb/BreadcrumbBar.xaml +++ b/dev/Breadcrumb/BreadcrumbBar.xaml @@ -7,27 +7,26 @@ xmlns:contract7NotPresent="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractNotPresent(Windows.Foundation.UniversalApiContract,7)">