Skip to content
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

Selection does not always change #19

Open
tapz opened this issue Jun 28, 2018 · 5 comments
Open

Selection does not always change #19

tapz opened this issue Jun 28, 2018 · 5 comments

Comments

@tapz
Copy link

tapz commented Jun 28, 2018

Does not seem to work very reliably. Usually need to tap the item several times before it's selected. The color changes so the component seems to recognize the touch, but does not change the selection (and onPress not called). I have two items, each having a customImageView and no text. I have forced the width to 150 by wrapping the SwitchSelector to a View.

I tested in Android 8.1.

@jkdrangel
Copy link
Contributor

I tried simulate here and is working. You tried it with debug remote enable? Sometimes debug remote delay actions with animations.

@tapz
Copy link
Author

tapz commented Jun 28, 2018

I started a debug build from the command line, but did not have a debugger connected. Remote logging was enabled, though.

@mjm918
Copy link

mjm918 commented Jul 4, 2019

In my case, I can change the selection once only. If I wanna change the value without pressing on the button, it only work on the first time.

Steps to simulate:

  1. change the value by changing the state
  2. press on a different selection
  3. try to change the value again by changing the state (does not work)

@mjm918
Copy link

mjm918 commented Jul 4, 2019

This is my code:

                                <SwitchSelector
                                        buttonColor={COLOR_BLUE}
                                        borderColor={COLOR_BLUE}
                                        options={uomList}
                                        value={this.state.selectedSwitch}
                                        initial={this.state.selectedSwitch}
                                        onPress={value => this.uomSelect(value)}
                                    />

In your source code I saw this:

if (nextProps.value !== this.props.value) {

If in my this.uomSelect function I get the index of value and set this.setState({selectedSwitch : pressedIndex}). After that I try to change the value from other function without pressing on the button, it works fine. Not sure if I could explain properly

@danghung24031992
Copy link

same me

motiz88 added a commit to motiz88/gr55-remote that referenced this issue Dec 24, 2022
react-native-switch-selector is broken (App2Sales/react-native-switch-selector#19) and has wrong-sized touch targets. SegmentedControl is a decent drop-in replacement (even though it doesn't attempt to support swiping).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants