Skip to content

Commit fa2bc1d

Browse files
authored
Fix WheelPicker issue with RTL on iOS (#1581)
1 parent 8d716d6 commit fa2bc1d

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/incubator/WheelPicker/index.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ const WheelPicker = ({
9797
labelStyle,
9898
labelProps,
9999
onChange,
100-
align,
100+
align = WheelPickerAlign.CENTER,
101101
style,
102102
children,
103103
initialValue,
@@ -181,13 +181,13 @@ const WheelPicker = ({
181181
},
182182
[onChange]);
183183

184-
const alignmentStyle = useMemo(() =>
185-
align === WheelPickerAlign.RIGHT
186-
? {alignSelf: 'flex-end'}
184+
const alignmentStyle = useMemo(() => {
185+
return align === WheelPickerAlign.RIGHT
186+
? {alignSelf: undefined}
187187
: align === WheelPickerAlign.LEFT
188188
? {alignSelf: 'flex-start'}
189-
: {alignSelf: 'center'},
190-
[align]);
189+
: {alignSelf: 'center'};
190+
}, [align]);
191191

192192
const renderItem = useCallback(({item, index}) => {
193193
return (
@@ -283,6 +283,8 @@ const WheelPicker = ({
283283
getItemLayout={getItemLayout}
284284
initialScrollIndex={currentIndex}
285285
onContentSizeChange={updateFlatListWidth}
286+
/* This fixes an issue with RTL when centering flatlist content using alignSelf */
287+
centerContent={align === 'center' && Constants.isRTL}
286288
/>
287289
</View>
288290
</View>

0 commit comments

Comments
 (0)