Skip to content

Commit 971c2ba

Browse files
authored
fix: move setting default values of medium-detent related props to InnerScreen (#1811)
## Description Default values for medium-detent related props were set only in `NativeStackView` so only in case user used native stack directly from `react-native-screens`. This led to buggy behaviour when `@react-navigation/native-stack` was in use. See conversation: #1686 (comment) ## Changes Default prop values are now set in `InnerScreen` in `index.native.tsx` which is used internally by `@react-navigation/native-stack` package. # Test case See conversation: #1686 (comment) (and below). Use `stackPresentation: 'formSheet'` with native stack from `@react-navigation/native-stack` and see that the modal is opened by default to full height. ## Checklist - [x] Ensured that CI passes
1 parent 159c2fb commit 971c2ba

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/index.native.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,16 @@ class InnerScreen extends React.Component<ScreenProps> {
261261
...rest
262262
} = this.props;
263263

264+
// To maintain default behaviour of formSheet stack presentation style & and to have resonable
265+
// defaults for new medium-detent iOS API we need to set defaults here
266+
const {
267+
sheetAllowedDetents = 'large',
268+
sheetLargestUndimmedDetent = 'all',
269+
sheetGrabberVisible = false,
270+
sheetCornerRadius = -1.0,
271+
sheetExpandsWhenScrolledToEdge = true,
272+
} = rest;
273+
264274
if (enabled && isPlatformSupported) {
265275
AnimatedNativeScreen =
266276
AnimatedNativeScreen ||
@@ -300,6 +310,11 @@ class InnerScreen extends React.Component<ScreenProps> {
300310
<AnimatedNativeScreen
301311
{...props}
302312
activityState={activityState}
313+
sheetAllowedDetents={sheetAllowedDetents}
314+
sheetLargestUndimmedDetent={sheetLargestUndimmedDetent}
315+
sheetGrabberVisible={sheetGrabberVisible}
316+
sheetCornerRadius={sheetCornerRadius}
317+
sheetExpandsWhenScrolledToEdge={sheetExpandsWhenScrolledToEdge}
303318
gestureResponseDistance={{
304319
start: gestureResponseDistance?.start ?? -1,
305320
end: gestureResponseDistance?.end ?? -1,

0 commit comments

Comments
 (0)