react-native-picker-select icon indicating copy to clipboard operation
react-native-picker-select copied to clipboard

Select won't close on iOS

Open danecando opened this issue 5 years ago • 40 comments

Describe the bug
Select window doesn't close when clicked outside or done is pressed.

To Reproduce
Create a simple select box and try to use it.

Expected behavior
Select View should close and onDonePress should be called when clicked

Screenshots
2019-12-19 15 19 54

Additional details

  • Device: iPad 7th Gen Emulator
  • OS: iOS 13.3
  • react-native-picker-select version: 6.3.3
  • react-native version: 0.61
  • react version: 16.9
  • expo sdk 36

Reproduction and/or code sample
Unfortunately it works in an expo snack so I haven't figured out why it isn't working my project environment. Hopefully it's not just me and someone can point me in the right direction.

danecando avatar Dec 19 '19 20:12 danecando

It isn't just you. Plese does this have a solution. I haven't been able to complete my project because of this.

papidb avatar Dec 25 '19 10:12 papidb

I don't know why but setting the Picker height 1 unit less than the modalViewBottom and adding overflow hidden solves the problem.

<RNPickerSelect pickerProps={{ style: { height: 214, overflow: 'hidden' } }} />

gamezinfantes avatar Dec 27 '19 15:12 gamezinfantes

Will try this now. Thanks in advanced!

papidb avatar Dec 27 '19 15:12 papidb

I'm experiencing the same issue. I'm at the point where I have built my own toggle and my own modal, importing the default Picker component from react-native. However I seem to be able to reproduce the same bug outside of this package. It seems the Picker covers the entire screen somehow, and catches any and all interaction.

It might have to do with some weird picker-in-modal interaction. If anyone finds a solution, I would be happy to hear it.

mattmattvanvoorst avatar Jan 23 '20 16:01 mattmattvanvoorst

I created #274 to address the issue.

adrianso avatar Jan 24 '20 03:01 adrianso

@gamezinfantes What version are you on? I tried your workaround but don't seem to work. I'm on version 6.6.0. Also, are there any other workaround?

maharjanaman avatar Apr 07 '20 10:04 maharjanaman

just spun up a brand new app.

react 16.11 react-native 0.62.2 react-native-picker-select 7.0.0

ran with react-native run-ios '--simulator=iPad (7th generation)'

not seeing the issue.

seems to be a legit issue based on the activity here - but someone will need to provide me with a reproduction.

lfkwtz avatar Apr 09 '20 21:04 lfkwtz

@lfkwtz Can you try it in expo? @danecando seems to be on expo and I too am using expo sdk 35. Besides that, I'm connecting it with redux-form.

maharjanaman avatar Apr 10 '20 02:04 maharjanaman

just tried expo - worked fine. i'll need a repro on this.

lfkwtz avatar Apr 10 '20 14:04 lfkwtz

Mine was on expo sdk 35.0.0 and with version 6.1.0 of react-native-picker-select. I upgraded to latest react-native-picker-select but there was still an issue.

maharjanaman avatar Apr 16 '20 03:04 maharjanaman

then please share code since you are able to reproduce it

lfkwtz avatar Apr 16 '20 11:04 lfkwtz

@lfkwtz as I said that I'm connecting it to redux-form, so here is how I implemented it

import React from "react";
import { View, StyleSheet, Text } from "react-native";
import RNPickerSelect from "react-native-picker-select";
import { Feather } from "@expo/vector-icons";
import PropTypes from "prop-types";

import { Colors, ConstStyles } from "../../constants";

const pickerSelectStyles = StyleSheet.create({
  inputIOS: {
    fontFamily: "workSansRegular",
    fontSize: 16,
    height: 75,
    borderWidth: 1,
    borderColor: Colors.munsell,
    borderRadius: 5,
    backgroundColor: Colors.munsell,
    paddingHorizontal: 20,
    paddingRight: 35,
    color: Colors.darkest
  },
  inputAndroid: {
    fontFamily: "workSansRegular",
    fontSize: 16,
    height: 75,
    borderWidth: 1,
    borderColor: Colors.munsell,
    borderRadius: 5,
    backgroundColor: Colors.munsell,
    paddingHorizontal: 20,
    paddingRight: 35,
    color: Colors.darkest
  }
});

const PickerSelect = ({
  items,
  height,
  containerStyle,
  showIcon,
  customIconContainer,
  input: { value, onChange },
  meta: { touched, error },
  ...custom
}) => (
  <View style={[{ paddingVertical: 5 }, containerStyle]}>
    <RNPickerSelect
      style={{
        ...pickerSelectStyles,
        inputIOS: {
          ...pickerSelectStyles.inputIOS,
          height,
          borderWidth: touched && error ? 2 : 1,
          borderColor: touched && error ? Colors.lightRed : Colors.munsell
        },
        inputAndroid: {
          ...pickerSelectStyles.inputAndroid,
          height,
          borderWidth: touched && error ? 2 : 1,
          borderColor: touched && error ? Colors.lightRed : Colors.munsell
        },
        iconContainer: {
          top: height === 50 ? 10 : 20,
          right: 10,
          ...customIconContainer
        }
      }}
      items={items}
      value={value}
      onValueChange={onChange}
      Icon={() => {
        return showIcon && <Feather name="chevron-down" size={30} color={Colors.light} />;
      }}
      {...custom}
      useNativeAndroidPickerStyle={false}
    />

    {touched && error && <Text style={ConstStyles.errorText}>{error}</Text>}
  </View>
);

export default PickerSelect;

PickerSelect.propTypes = {
  items: PropTypes.instanceOf(Array),
  input: PropTypes.shape({
    value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
    onChange: PropTypes.func
  }),
  meta: PropTypes.shape({
    touched: PropTypes.bool,
    error: PropTypes.oneOfType([PropTypes.object, PropTypes.string])
  }),
  height: PropTypes.number,
  containerStyle: PropTypes.shape({}),
  showIcon: PropTypes.bool,
  customIconContainer: PropTypes.shape({})
};

PickerSelect.defaultProps = {
  items: [],
  input: {},
  meta: {},
  height: 75,
  containerStyle: {},
  showIcon: true,
  customIconContainer: {}
};

And here is piece of redux-form code

<Field
  key={index}
  name={specificPosition}
  items={pickerItems}
  component={PickerSelect}
  placeholder={{
     label: "SPECIFIC POSITION",
     value: null
 }}
 placeholderTextColor={Colors.taupe}
/>

Hope this helps.

maharjanaman avatar Apr 16 '20 11:04 maharjanaman

some problem

Arwantys avatar Apr 18 '20 20:04 Arwantys

Any updates here? The suggestion for a workaround only resolves the issue for one of my pickers and it breaks the whole thing on Android. image

KristenKatona avatar May 08 '20 16:05 KristenKatona

if someone can share a full repro with me, i'd be happy to look into it. @KristenKatona i'm especially curious why this would only fix one of your pickers - what is unique about it?

lfkwtz avatar May 12 '20 19:05 lfkwtz

@lfkwtz the picker it did NOT fix (on iOS only) was within an extra nested view vs the one that did work. I just removed that extra inner view and it worked. I didn't use the suggestion here at all, I just removed that extra inner view.

KristenKatona avatar May 12 '20 19:05 KristenKatona

Having the same issue. Example snack: https://snack.expo.io/@ptgodev/nervous-chocolate

Expo client on iOS Simulator. iPhone 8, 13.3.

rickysullivan avatar May 19 '20 08:05 rickysullivan

@rickysullivan just pulled that down and ran on expo-cli with iPhone 8

Untitled

lfkwtz avatar May 19 '20 15:05 lfkwtz

Which cli version?

rickysullivan avatar May 19 '20 19:05 rickysullivan

3.20.9

lfkwtz avatar May 19 '20 19:05 lfkwtz

Expo client app or did you build a standalone?

rickysullivan avatar May 19 '20 19:05 rickysullivan

client

lfkwtz avatar May 19 '20 19:05 lfkwtz

Client version?

rickysullivan avatar May 19 '20 19:05 rickysullivan

2.15.4.10229

lfkwtz avatar May 19 '20 20:05 lfkwtz

issue-264

Sim: iPhone 8 @ iOS 13.3 Expo client: 2.15.4.10229

rickysullivan avatar May 19 '20 20:05 rickysullivan

Strange, my actual project is now working. issue-264-working

rickysullivan avatar May 19 '20 20:05 rickysullivan

I'm facing this issue as well, I've placed console log in the code in line 343 corresponding to the onPress of the "Done" button, it seems the onPress event never gets triggered, by such the modal is never dismissed. Why wouldn't a TouchableOpacity trigger the onPress event but trigger others?.. what is even more strange is that this issue went away without me modifying anything, it just goes and comes, is difficult to figure what is causing this behaviour.

Edit: only the onPress event was not triggering, others as onPressIn or onPressOut found in the same TouchableOpacity component were being triggered.

randomBrainstormer avatar Jun 04 '20 18:06 randomBrainstormer

any solutions?

SmirnovM91 avatar Jun 06 '20 10:06 SmirnovM91

Seeing this issue as well.

RN: 0.62.2 "react-native-picker-select": "^7.0.0", No Expo

micnguyen avatar Jul 11 '20 15:07 micnguyen

if you’re seeing this issue, please provide a repro

lfkwtz avatar Jul 11 '20 23:07 lfkwtz