question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

textInputProps not working as expected

See original GitHub issue

Describe the bug
I want the picker to ellipsize text that is too long.

To Reproduce
I am using the RNPickerSelect inside of a styled component. It also uses an Icon, which after reading some of the other issues, could be a source of the problem.

Expected behavior
After adding the textInputProps = {{numberOfLines: 1, ellipsizeMode: 'tail'}} I expected the issue to go away. However, it doesn’t work as expected, but it does not lead to any further errors.

Screenshots
image

Additional details

  • Android emulator
  • If I set the useNativeAndroidPicker to true, it does ellipsize. However, the icon does not respond to being clicked.
  • Adding numberOfLines or ellipsizeMode to the styleSheet throws error.

Reproduction and/or code sample

<RNPickerSelect
          placeholder={{
            label: `${i18n.t('selectABoard')}`,
            value: null,
          }}
          items={items}
          onValueChange={
            value => {
              if (value != null && value !== selected) {
                if (boards.find(board => board.name === value.name)) {
                  onBoardSelected(value);
                } else {
                  onCommitteeSelected(value);
                }
              }
            }
          }
          value={selected}
          style={stylesPicker}
          Icon={() => (
            <IconContainer>
              <Entypo
                name="chevron-down"
                color={colors.PRIMARY_BLUE}
                size={20}
              />
            </IconContainer>
          )}
          useNativeAndroidPickerStyle={false}
          textInputProps={{numberOfLines: 1}}
        />

const stylesPicker = StyleSheet.create({
  placeholder: {
    color: colors.PRIMARY_BLUE,
  },
  inputIOS: {
    color: colors.PRIMARY_BLUE,
    height: NAVBAR_HEIGHT,
    paddingLeft: 16,
    paddingRight: 16,
  },
  inputAndroid: {
    color: colors.PRIMARY_BLUE,
    height: NAVBAR_HEIGHT,
    paddingLeft: 16,
    paddingRight: 16,
  },
  iconContainer: {
    alignItems: 'center',
    height: NAVBAR_HEIGHT,
    justifyContent: 'center',
    paddingRight: 16,
  }
});

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Ramaraju1992commented, Mar 17, 2022

@Andrea-Arguello, @lfkwtz i am also facing the same issue. but i found some TextInput prop that can show the selected text from starting.

textInputProps={{ selection: { start: 0 } }}

but unfortunately for ellipsizeMode: 'tail' Repository Team has to help.

1reaction
Andrea-Arguellocommented, Sep 10, 2019

After using the snack provided in this repo https://snack.expo.io/@lfkwtz/react-native-picker-select, I noticed that the issue is reproducible for all pickers with useNativeAndroidPickerStyle set to false, if the text is long enough. image Adding textInputProps = {{numberOfLines: 1}} does not fix this. Our case seems to be similar to the custom icon pickers, which do this image

Read more comments on GitHub >

github_iconTop Results From Across the Web

React native custom component props not working
Hey there so I am trying to use a custom text input and giving it props like autoCorrect, autoCapitalise, etc but for some...
Read more >
TextInput - React Native
TextInput. A foundational component for inputting text into the app via a keyboard. Props provide configurability for several features, ...
Read more >
TextInput Props in React Native - Medium
The game worked on the web browser, but nothing got triggered on the simulator. I realized that I did not need the e.nativeEvent.key...
Read more >
onChangeText not working as expected while using useState
The Keybord Closes after each keyPress. I followed this while trying to handle TextInputs but the keyboard closes every time I press a...
Read more >
UI Kitten - Input - component api - GitHub Pages
If it is a function, expected to return a Text. caption, ReactElement | ReactText | (TextProps) => ReactElement ... TextInputProps, TextInputProps.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found