Skip to content

Commit c92aab1

Browse files
authored
Merge pull request #9 from OlimpiaZurek/web_picker_white_spaces
2 parents 6d20efb + bb3046e commit c92aab1

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ import { Dimensions } from 'react-native';
1010
// This height was tested thoroughly on several iPhone Models (from iPhone 8 to 14 Pro)
1111
const IOS_MODAL_HEIGHT = 262;
1212

13+
const preserveSpaces = (label) => {
14+
return label.replace(/ /g, '\u00a0');
15+
}
16+
1317
export default class RNPickerSelect extends PureComponent {
1418
static propTypes = {
1519
onValueChange: PropTypes.func.isRequired,
@@ -298,7 +302,7 @@ export default class RNPickerSelect extends PureComponent {
298302
return items.map((item) => {
299303
return (
300304
<Picker.Item
301-
label={item.label}
305+
label={Platform.OS === 'web' ? preserveSpaces(item.label) : item.label} // remove this once this PR is merged https://github.com/react-native-picker/picker/pull/485
302306
value={item.value}
303307
key={item.key || item.label}
304308
color={item.color}

0 commit comments

Comments
 (0)