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

[iOS] Slider doesn't trigger onValueChange/onSlidingComplete when adjusted with Detox adjustSliderToPosition() #351

Open
MoOx opened this issue Jan 24, 2022 · 9 comments
Labels
bug report Something isn't working

Comments

@MoOx
Copy link

MoOx commented Jan 24, 2022

Environment

❯ react-native info
info Fetching system and libraries information...
System:
OS: macOS 12.1
CPU: (10) arm64 Apple M1 Pro
Memory: 201.50 MB / 16.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 16.13.2 - /var/folders/51/8pncdp0x14d04bbk454szsnw0000gn/T/fnm_multishells/16782_1643016955991/bin/node
Yarn: 1.22.5 - ~/.yarn/bin/yarn
npm: 8.1.2 - /var/folders/51/8pncdp0x14d04bbk454szsnw0000gn/T/fnm_multishells/16782_1643016955991/bin/npm
Watchman: 2022.01.03.00 - /opt/homebrew/bin/watchman
Managers:
CocoaPods: 1.11.2 - /Users/moox/.gem/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 21.2, iOS 15.2, macOS 12.1, tvOS 15.2, watchOS 8.3
Android SDK: Not Found
IDEs:
Android Studio: Not Found
Xcode: 13.2.1/13C100 - /usr/bin/xcodebuild
Languages:
Java: 11.0.10 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: ^17.0.2 => 17.0.2
react-native: 0.67.0-rc.6 => 0.67.0-rc.6
react-native-macos: Not Found
npmGlobalPackages:
react-native: Not Found

Description

I am using detox to automated some tests and just faced the fact that using adjustSliderToPosition() API doesn't trigger onValueChange nor onSlidingComplete, so in my case it's like the slider hasn't been moved (it is, visually, but programmatically, no call have been made)

Reproducible Demo

I can't really do a quick demo :/

@MoOx MoOx added the bug report Something isn't working label Jan 24, 2022
@MoOx MoOx changed the title Slider doesn't trigger onValueChange when adjusted with Detox adjustSliderToPosition() [iOS] Slider doesn't trigger onValueChange when adjusted with Detox adjustSliderToPosition() Jan 24, 2022
@BartoszKlonowski
Copy link
Member

Hello @MoOx!
It's always good to specify the version you are using, so I can analyse this right away instead of bothering you with asking about it.
Especially, there's been a 4.2.0 release just yesterday.

@BartoszKlonowski BartoszKlonowski added the requires: author feedback Item requires some author's action label Jan 24, 2022
@MoOx MoOx changed the title [iOS] Slider doesn't trigger onValueChange when adjusted with Detox adjustSliderToPosition() [iOS] Slider doesn't trigger onValueChange/onSlidingComplete when adjusted with Detox adjustSliderToPosition() Jan 24, 2022
@MoOx
Copy link
Author

MoOx commented Jan 24, 2022

I tried this version right now, I am facing the same problem.

@BartoszKlonowski BartoszKlonowski removed the requires: author feedback Item requires some author's action label Jan 24, 2022
@BartoszKlonowski
Copy link
Member

@MoOx Thanks! I will take a look into that.

@MoOx
Copy link
Author

MoOx commented Jan 24, 2022

Thanks a lot!

@MoOx
Copy link
Author

MoOx commented Jan 24, 2022

Just in case somebody is looking for a workaround: just use Detox swipe() method with the proper argument so it works for you (in my case a simple await element(by.id('GoalEdit_durationSlider')).swipe('right', 'slow', 0.3, 0); did the trick.

@NitishSystango
Copy link

@MoOx I am getting the same issue but above trick not working for me. Do you have any other solution? (I am guessing GoalEdit_durationSlider is you slider view testID)

Anyone else having any solution for this?

@MoOx
Copy link
Author

MoOx commented Jun 22, 2022

I didn't look for any other solution since the previous one works for me perfectly.

@dmontag23
Copy link

I'm seeing the same issue.

@gliang-lyra
Copy link

gliang-lyra commented Mar 9, 2024

Try to use the longPressAndDrag, for example:

# sliderElem and targetElem could be the same element
const sliderElem = element(by.id('elementToDrag'))
const targetElem = element(by.id('targetElem'))
const duration = 2000
const endingPosition = 0.9 

await sliderElem.longPressAndDrag(duration, NaN, NaN, targetElem, endingPosition, NaN, 'slow', 0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Something isn't working
Projects
Status: To be analyzed
Development

No branches or pull requests

5 participants