Skip to content

Commit

Permalink
Fix intermittent layout problem when View contains a Content Control.…
Browse files Browse the repository at this point in the history
… Also remove IsTabStop from ScrollViewer.
  • Loading branch information
randy-flynn committed Mar 20, 2019
1 parent 14f228a commit 85cb9a8
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 8 deletions.
3 changes: 0 additions & 3 deletions RNWCPP/ReactUWP/Views/ScrollViewManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,6 @@ XamlView ScrollViewManager::CreateViewCore(int64_t tag)
winrt::ScrollViewer scrollViewer;

AddHandlers(scrollViewer, tag);
// Enable as tabstop so clicks inside don't move focus to the first element.
// FUTURE: expose prop to control this
scrollViewer.IsTabStop(true);

return scrollViewer;
}
Expand Down
13 changes: 8 additions & 5 deletions RNWCPP/ReactUWP/Views/ViewPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,21 @@ void ViewPanel::SetLeft(winrt::Windows::UI::Xaml::UIElement& element, double val

winrt::Size ViewPanel::MeasureOverride(winrt::Size availableSize)
{
// All children are given as much size as they'd like
winrt::Size childConstraint(INFINITY, INFINITY);

for (winrt::UIElement child : Children())
{
child.Measure(winrt::Size(INFINITY, INFINITY));
child.Measure(childConstraint);

auto width = child.DesiredSize().Width;
auto height = child.DesiredSize().Height;

width = width;
}

return winrt::Size(availableSize.Width == INFINITY ? 0.0f : availableSize.Width, availableSize.Height == INFINITY ? 0.0f : availableSize.Height);
// ViewPanels never choose their size, that is completely up to the parent - so return no size
return winrt::Size(0, 0);
}

winrt::Size ViewPanel::ArrangeOverride(winrt::Size finalSize)
Expand All @@ -187,9 +193,6 @@ winrt::Size ViewPanel::ArrangeOverride(winrt::Size finalSize)
float left = (float)ViewPanel::GetLeft(child);
float top = (float)ViewPanel::GetTop(child);

auto width = child.DesiredSize().Width;
auto height = child.DesiredSize().Height;

if ((child != m_border) && (child != m_innerElement))
child.Arrange(winrt::Rect(left, top, child.DesiredSize().Width, child.DesiredSize().Height));
else
Expand Down
16 changes: 16 additions & 0 deletions RNWCPP/ReactUWP/Views/ViewViewManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,4 +401,20 @@ void ViewViewManager::ReplaceView(ViewShadowNode* pViewShadowNode, bool useContr
}
}

void ViewViewManager::SetLayoutProps(ShadowNodeBase& nodeToUpdate, XamlView viewToUpdate, float left, float top, float width, float height)
{
// When the View has a ContentControl the ViewPanel must also have the Width & Height set
// Do this first so that it is setup properly before any events are fired by the Super implementation
auto* pViewShadowNode = static_cast<ViewShadowNode*>(&nodeToUpdate);
if (pViewShadowNode->IsControl())
{
auto* pPanel = pViewShadowNode->GetViewPanel();
pPanel->Width(width);
pPanel->Height(height);
}

Super::SetLayoutProps(nodeToUpdate, viewToUpdate, left, top, width, height);
}


} }
3 changes: 3 additions & 0 deletions RNWCPP/ReactUWP/Views/ViewViewManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ class ViewViewManager : public FrameworkElementViewManager

void UpdateProperties(ShadowNodeBase* nodeToUpdate, folly::dynamic reactDiffMap) override;

// Yoga Layout
void SetLayoutProps(ShadowNodeBase& nodeToUpdate, XamlView viewToUpdate, float left, float top, float width, float height) override;

protected:
XamlView CreateViewCore(int64_t tag) override;
void ReplaceView(ViewShadowNode* viewShadowNode, bool useControl);
Expand Down

0 comments on commit 85cb9a8

Please sign in to comment.