Skip to content

Fix WheelPicker issue with RTL on iOS #1581

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

Merged
merged 1 commit into from
Oct 3, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/incubator/WheelPicker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const WheelPicker = ({
labelStyle,
labelProps,
onChange,
align,
align = WheelPickerAlign.CENTER,
style,
children,
initialValue,
Expand Down Expand Up @@ -181,13 +181,13 @@ const WheelPicker = ({
},
[onChange]);

const alignmentStyle = useMemo(() =>
align === WheelPickerAlign.RIGHT
? {alignSelf: 'flex-end'}
const alignmentStyle = useMemo(() => {
return align === WheelPickerAlign.RIGHT
? {alignSelf: undefined}
: align === WheelPickerAlign.LEFT
? {alignSelf: 'flex-start'}
: {alignSelf: 'center'},
[align]);
: {alignSelf: 'center'};
}, [align]);

const renderItem = useCallback(({item, index}) => {
return (
Expand Down Expand Up @@ -283,6 +283,8 @@ const WheelPicker = ({
getItemLayout={getItemLayout}
initialScrollIndex={currentIndex}
onContentSizeChange={updateFlatListWidth}
/* This fixes an issue with RTL when centering flatlist content using alignSelf */
centerContent={align === 'center' && Constants.isRTL}
/>
</View>
</View>
Expand Down