From 327128b074456cf5dfc8b4e5234377756312a9ee Mon Sep 17 00:00:00 2001 From: Stephen L Peters Date: Thu, 24 Feb 2022 10:26:30 -0800 Subject: [PATCH] Fix TeachingTip getting stuck closed (#6541) * Ignore IsOpen property changes while there are active animations to avoid getting into a state where the tip isn't being displaced despite IsOpen being true. * Fix issue with tips which do not fit leaving the tip in a state that is not interactable. --- dev/TeachingTip/TeachingTip.cpp | 38 ++++++++++++++++++++++----------- dev/TeachingTip/TeachingTip.h | 1 + 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/dev/TeachingTip/TeachingTip.cpp b/dev/TeachingTip/TeachingTip.cpp index 17690cf581..61ec366a1e 100644 --- a/dev/TeachingTip/TeachingTip.cpp +++ b/dev/TeachingTip/TeachingTip.cpp @@ -788,18 +788,31 @@ void TeachingTip::UpdateDynamicHeroContentPlacementToBottomImpl() void TeachingTip::OnIsOpenChanged() { - SharedHelpers::QueueCallbackForCompositionRendering([strongThis = get_strong()]() + if (m_ignoreNextIsOpenChanged) { + m_ignoreNextIsOpenChanged = false; + } + else { - if (strongThis->IsOpen()) - { - strongThis->IsOpenChangedToOpen(); - } - else + SharedHelpers::QueueCallbackForCompositionRendering([strongThis = get_strong()]() { - strongThis->IsOpenChangedToClose(); - } - TeachingTipTestHooks::NotifyOpenedStatusChanged(*strongThis); - }); + if (strongThis->m_isIdle) { + if (strongThis->IsOpen()) + { + strongThis->IsOpenChangedToOpen(); + } + else + { + strongThis->IsOpenChangedToClose(); + } + TeachingTipTestHooks::NotifyOpenedStatusChanged(*strongThis); + } + else + { + strongThis->m_ignoreNextIsOpenChanged = true; + strongThis->IsOpen(!strongThis->IsOpen()); + } + }); + } } void TeachingTip::IsOpenChangedToOpen() @@ -844,9 +857,6 @@ void TeachingTip::IsOpenChangedToOpen() CreateExpandAnimation(); } - // We are about to begin the process of trying to open the teaching tip, so notify that we are no longer idle. - SetIsIdle(false); - //If the developer defines their TeachingTip in a resource dictionary it is possible that it's template will have never been applied if (!m_isTemplateApplied) { @@ -877,6 +887,8 @@ void TeachingTip::IsOpenChangedToOpen() { if (!popup.IsOpen()) { + // We are about to begin the process of trying to open the teaching tip, so notify that we are no longer idle. + SetIsIdle(false); UpdatePopupRequestedTheme(); popup.Child(m_rootElement.get()); if (auto&& lightDismissIndicatorPopup = m_lightDismissIndicatorPopup.get()) diff --git a/dev/TeachingTip/TeachingTip.h b/dev/TeachingTip/TeachingTip.h index 9d01bd89e2..c1e2144ad4 100644 --- a/dev/TeachingTip/TeachingTip.h +++ b/dev/TeachingTip/TeachingTip.h @@ -209,6 +209,7 @@ class TeachingTip : winrt::Size m_currentXamlRootSize{ 0,0 }; + bool m_ignoreNextIsOpenChanged{ false }; bool m_isTemplateApplied{ false }; bool m_createNewPopupOnOpen{ false };