mirror of
https://github.com/zhigang1992/react-native-web.git
synced 2026-03-26 01:04:13 +08:00
[fix] Picker.Item label text
Render the label as a child of 'option' rather than using the 'label' attribute. Fix #774
This commit is contained in:
@@ -20,6 +20,6 @@ export default class PickerItem extends Component<Props> {
|
||||
|
||||
render() {
|
||||
const { label, testID, value } = this.props;
|
||||
return createElement('option', { label, testID, value });
|
||||
return createElement('option', { testID, value }, label);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`components/Picker prop "children" items 1`] = `
|
||||
<option
|
||||
value="value-1"
|
||||
>
|
||||
label-1
|
||||
</option>
|
||||
`;
|
||||
|
||||
exports[`components/Picker prop "children" renders items 1`] = `
|
||||
<select
|
||||
className="rn-fontFamily-poiln3 rn-fontSize-7cikom rn-marginTop-1mnahxq rn-marginRight-61z16t rn-marginBottom-p1pxzi rn-marginLeft-11wrixw"
|
||||
|
||||
@@ -16,6 +16,12 @@ describe('components/Picker', () => {
|
||||
const component = shallow(picker);
|
||||
expect(component).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('items', () => {
|
||||
const pickerItem = <Picker.Item label="label-1" value="value-1" />;
|
||||
const component = shallow(pickerItem);
|
||||
expect(component).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
||||
describe('prop "enabled"', () => {
|
||||
|
||||
Reference in New Issue
Block a user