Skip to content

Commit dca6b04

Browse files
committed
fix: ios width
1 parent ccbc33d commit dca6b04

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

ios/RNDateTimePicker.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ - (instancetype)initWithFrame:(CGRect)frame
3232
#endif
3333

3434
_reactMinuteInterval = 1;
35+
36+
// Ensure the picker can expand to fill its container
37+
self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
3538
}
3639
return self;
3740
}

src/datetimepicker.ios.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
IOS_MODE,
1919
} from './constants';
2020
import * as React from 'react';
21-
import {Platform} from 'react-native';
21+
import {Platform, StyleSheet} from 'react-native';
2222

2323
import type {
2424
DateTimePickerEvent,
@@ -59,6 +59,7 @@ export default function Picker({
5959
display: providedDisplay = IOS_DISPLAY.default,
6060
// $FlowFixMe[incompatible-type]
6161
disabled = false,
62+
style,
6263
...other
6364
}: IOSNativeProps): React.Node {
6465
sharedPropsValidation({value, timeZoneOffsetInMinutes, timeZoneName, minimumDate, maximumDate});
@@ -92,9 +93,21 @@ export default function Picker({
9293
);
9394
};
9495

96+
// For inline/calendar display, ensure the component takes full width by default
97+
const computedStyle = React.useMemo(() => {
98+
if (display === IOS_DISPLAY.inline) {
99+
return StyleSheet.compose(
100+
{alignSelf: 'stretch'},
101+
style,
102+
);
103+
}
104+
return style;
105+
}, [display, style]);
106+
95107
return (
96108
<RNDateTimePicker
97109
{...other}
110+
style={computedStyle}
98111
date={dateToMilliseconds(value)}
99112
locale={locale !== null && locale !== '' ? locale : undefined}
100113
maximumDate={dateToMilliseconds(maximumDate)}

0 commit comments

Comments
 (0)