Skip to content

Commit

Permalink
feat: adds support for supportedOrientations (#224)
Browse files Browse the repository at this point in the history
fixes Landscape mode in BottomSheet fails accessibility test #223
  • Loading branch information
proohit authored Aug 8, 2024
1 parent 128f514 commit 92e5b51
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/extras/docs/BottomSheet.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,14 @@ A `ref` object used to call `close` and `isVisible` functions on the bottomSheet
| ----------------------------------------------------------- |
| `{ close: () => Promise<void>; isVisible: () => boolean; }` |

### `supportedOrientations`

iOS only. An array of strings that specify the orientations supported by the bottom sheet. Type is defined by [React Native Modal](https://reactnative.dev/docs/modal#supportedorientations-ios)

| Type |
| ---------------------------------------------------------------------------------------- |
| `['portrait', 'portrait-upside-down', 'landscape', 'landscape-left', 'landscape-right']` |

## Known issues

If the app crashes with the following error:
Expand Down
4 changes: 4 additions & 0 deletions packages/extras/src/components/BottomSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
KeyboardAvoidingView,
LayoutChangeEvent,
Modal,
ModalProps,
Platform,
Pressable,
ScrollViewProps,
Expand Down Expand Up @@ -61,6 +62,7 @@ export type BottomSheetProps = {
visible: boolean;
ref?: React.RefObject<BottomSheetActions>;
shouldHandleKeyboardEvents?: boolean;
supportedOrientations?: ModalProps['supportedOrientations'];
};

export type BottomSheetActions = {
Expand Down Expand Up @@ -102,6 +104,7 @@ export const BottomSheet = React.forwardRef<
topInset,
onBottomSheetHidden,
shouldHandleKeyboardEvents = true,
supportedOrientations,
},
ref,
) => {
Expand Down Expand Up @@ -272,6 +275,7 @@ export const BottomSheet = React.forwardRef<
visible={isModalVisible}
onRequestClose={() => onClose()}
ref={ref as any}
supportedOrientations={supportedOrientations}
testID={testID}>
<Wrapper>
{renderContent ? (
Expand Down

0 comments on commit 92e5b51

Please sign in to comment.