Skip to content

Commit

Permalink
[UWP Renderer] Allow nested fallbacks (#8234)
Browse files Browse the repository at this point in the history
* Switch to gotFocus (#8148) (#8150)

* Update custom.props

* [UWP] Update custom.props for object model release (#8225)

* Update custom.props for object model release

* Updated Xcode version (#8222)

* removed build step as they are redundant (#8201)

* removed build step as they are redundant

* added pod installation step

Co-authored-by: Joseph Woo <Joseph.Woo@microsoft.com>

* [UWP Renderer] Add a null check to inline action rendering (#8228)

* Update custom.props for object model release

* Updated Xcode version (#8222)

* removed build step as they are redundant (#8201)

* removed build step as they are redundant

* added pod installation step

* Add a null check for inline Actions

Co-authored-by: Joseph Woo <Joseph.Woo@microsoft.com>

* Update fallback behavior

---------

Co-authored-by: Joseph Woo <Joseph.Woo@microsoft.com>
  • Loading branch information
anna-dingler and jwoo-msft authored Mar 20, 2023
1 parent ae38b66 commit 4037a50
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
13 changes: 12 additions & 1 deletion source/uwp/SharedRenderer/lib/XamlBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,18 @@ namespace AdaptiveCards::Rendering::Xaml_Rendering
throw ex;
}

std::tie(newControl, renderedElement) = XamlHelpers::RenderFallback(element, renderContext, renderArgs);
try
{
std::tie(newControl, renderedElement) = XamlHelpers::RenderFallback(element, renderContext, renderArgs);
}
catch (winrt::hresult_error const& ex)
{
// if we get an E_PERFORM_FALLBACK error again, we should only throw it if `ancestorHasFallBack`
if (ex.code() != E_PERFORM_FALLBACK || (ex.code() == E_PERFORM_FALLBACK && ancestorHasFallback))
{
throw ex;
}
}
}

// If we got a control, add a separator if needed and the control to the parent panel
Expand Down
23 changes: 18 additions & 5 deletions source/uwp/SharedRenderer/lib/XamlHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,15 +333,28 @@ namespace AdaptiveCards::Rendering::Xaml_Rendering::XamlHelpers

if (fallbackElementRenderer)
{
fallbackControl = fallbackElementRenderer.Render(fallbackElement, renderContext, renderArgs);

renderedElement = fallbackElement;
try
{
fallbackControl = fallbackElementRenderer.Render(fallbackElement, renderContext, renderArgs);
renderedElement = fallbackElement;
}
catch (winrt::hresult_error const& ex)
{
if (ex.code() == E_PERFORM_FALLBACK)
{
std::tie(fallbackControl, renderedElement) = RenderFallback(fallbackElement, renderContext, renderArgs);
}
else
{
throw(ex);
}
}
}

if (!fallbackControl)
else
{
std::tie(fallbackControl, renderedElement) = RenderFallback(fallbackElement, renderContext, renderArgs);
}

fallbackHandled = true;
break;
}
Expand Down

0 comments on commit 4037a50

Please sign in to comment.