-
Notifications
You must be signed in to change notification settings - Fork 734
Fix/wheel picker initial value on change #3029
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
Conversation
This reverts commit 2727fa1.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, wrote small comment on the flag
src/components/WheelPicker/index.tsx
Outdated
@@ -148,7 +148,7 @@ const WheelPicker = <T extends WheelPickerItemValue>(props: WheelPickerProps<T>) | |||
preferredNumVisibleRows: numberOfVisibleRows | |||
}); | |||
|
|||
const prevInitialValue = useRef(initialValue); | |||
const shouldInvokeOnChange = useRef(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better that the flag will represent the edge case and not the common case.
Meaning that false
will be the usual value, so it's better to name it something like shouldSkipNextOnChange
or something similar.
This way its value will be usually false and only when turning it on set it to true.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
* WheelPicker prevInitailValue setter changed * Revert "WheelPicker prevInitailValue setter changed" This reverts commit 2727fa1. * added handling for when a scroll is invoked by the user and not programatically * change WheelPicker Driver to invoke onScrollBeginDrag on moveToItem * changed naming * changed naming to be more explanatory * changed default skip value
Description
The WheelPicker was not invoking
onChange
if theinitialValue
was changed right afteronChange
was called. I added a handling for wether the drag is a user or a programatic scroll.Changelog
WheelPicker - Fix onChange not called when initial value is changed.
Additional info
MADS-4145