Skip to content

Commit

Permalink
Fix TeachingTip getting stuck closed (#6541)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
StephenLPeters authored Feb 24, 2022
1 parent cb580df commit 327128b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
38 changes: 25 additions & 13 deletions dev/TeachingTip/TeachingTip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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())
Expand Down
1 change: 1 addition & 0 deletions dev/TeachingTip/TeachingTip.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ class TeachingTip :

winrt::Size m_currentXamlRootSize{ 0,0 };

bool m_ignoreNextIsOpenChanged{ false };
bool m_isTemplateApplied{ false };
bool m_createNewPopupOnOpen{ false };

Expand Down

0 comments on commit 327128b

Please sign in to comment.