Skip to content

Expose placeholder prop on Picker #6552

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "none",
"comment": "Add placeholder prop to Picker",
"packageName": "react-native-windows",
"email": "[email protected]",
"dependentChangeType": "none"
}
7 changes: 7 additions & 0 deletions vnext/Microsoft.ReactNative/Views/PickerViewManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ void PickerShadowNode::updateProperties(winrt::Microsoft::ReactNative::JSValueOb
} else if (propertyName == "items") {
m_items = propertyValue.AsArray().Copy();
RepopulateItems();
} else if (propertyName == "placeholder") {
if (propertyValue.Type() == winrt::Microsoft::ReactNative::JSValueType::String) {
combobox.PlaceholderText(react::uwp::asHstring(propertyValue));
} else if (propertyValue.IsNull()) {
combobox.ClearValue(xaml::Controls::ComboBox::PlaceholderTextProperty());
}
}
}

Expand Down Expand Up @@ -194,6 +200,7 @@ void PickerViewManager::GetNativeProps(const winrt::Microsoft::ReactNative::IJSV
winrt::Microsoft::ReactNative::WriteProperty(writer, L"items", L"array");
winrt::Microsoft::ReactNative::WriteProperty(writer, L"selectedIndex", L"number");
winrt::Microsoft::ReactNative::WriteProperty(writer, L"text", L"string");
winrt::Microsoft::ReactNative::WriteProperty(writer, L"placeholder", L"string");
}

ShadowNode *PickerViewManager::createShadow() const {
Expand Down
1 change: 1 addition & 0 deletions vnext/src/Libraries/Components/Picker/PickerProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface IPickerProps extends ViewProps {
// tslint:disable-next-line:no-any
selectedValue?: any;
enabled?: boolean;
placeholder?: string;
prompt?: string;
testID?: string;
onChange?: (event: IPickerChangeEvent) => void;
Expand Down