Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Picker layout fix (WI:3391028) #2584

Merged
3 commits merged into from
Jun 7, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions vnext/ReactUWP/Views/PickerViewManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,16 @@ class PickerShadowNode : public ShadowNodeBase
PickerShadowNode();
void createView() override;
void updateProperties(const folly::dynamic&& props) override;
bool IsExternalLayoutDirty() const override { return m_hasNewItems; }
void DoExtraLayoutPrep(YGNodeRef yogaNode) override;

private:
void RepopulateItems();
static void OnSelectionChanged(IReactInstance& instance, int64_t tag, folly::dynamic&& value, int32_t selectedIndex, folly::dynamic&& text);

folly::dynamic m_items;
int32_t m_selectedIndex = -1;
bool m_hasNewItems = false;

// FUTURE: remove when we can require RS5+
bool m_isEditableComboboxSupported;
Expand All @@ -53,6 +56,17 @@ PickerShadowNode::PickerShadowNode()
m_isEditableComboboxSupported = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.UI.Xaml.Controls.ComboBox", L"IsEditableProperty");
}

void PickerShadowNode::DoExtraLayoutPrep(YGNodeRef yogaNode)
{
if (!m_hasNewItems)
return;

m_hasNewItems = false;

auto comboBox = GetView().try_as<winrt::ComboBox>();
comboBox.UpdateLayout();
}

void PickerShadowNode::createView()
{
Super::createView();
Expand Down Expand Up @@ -158,6 +172,7 @@ void PickerShadowNode::RepopulateItems()
comboboxItem.Foreground(BrushFrom(item["textColor"]));
comboBoxItems.Append(comboboxItem);
}
m_hasNewItems = true;
}
if (m_selectedIndex < static_cast<int32_t>(m_items.size()))
combobox.SelectedIndex(m_selectedIndex);
Expand Down