Skip to content
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

fix: add ability to turn off adding extra padding for keyboard #770

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions docs/docs/api/components/keyboard-aware-scroll-view.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ If you have _**sticky elements**_ above the keyboard and want to extend the keyb
This property acts as [extraScrollHeight](https://github.com/APSL/react-native-keyboard-aware-scroll-view/tree/9eee405f7b3e261faf86a0fc8e495288d91c853e?tab=readme-ov-file#props) from original [react-native-keyboard-aware-scroll-view](https://github.com/APSL/react-native-keyboard-aware-scroll-view) package.
:::

### `withKeyboardHeightPadding`

Specifies whether to add padding equal to the keyboard height. This is useful when working with components like a bottom sheet, where the bottom sheet manages the position of the modal above the keyboard. In such cases, adding extra padding for the keyboard is unnecessary.

## Integration with 3rd party components

### `FlatList`/`FlashList`/`SectionList` etc.
Expand Down
5 changes: 4 additions & 1 deletion src/components/KeyboardAwareScrollView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ export type KeyboardAwareScrollViewProps = {
enabled?: boolean;
/** Adjusting the bottom spacing of KeyboardAwareScrollView. Default is `0` */
extraKeyboardSpace?: number;
/** Specifies whether to add padding equal to the keyboard height. This is useful when working with components like a bottom sheet, where the bottom sheet manages the position of the modal above the keyboard. In such cases, adding extra padding for the keyboard is unnecessary. */
withKeyboardHeightPadding?: boolean;
/** Custom component for `ScrollView`. Default is `ScrollView` */
ScrollViewComponent?: React.ComponentType<ScrollViewProps>;
} & ScrollViewProps;
Expand Down Expand Up @@ -95,6 +97,7 @@ const KeyboardAwareScrollView = forwardRef<
extraKeyboardSpace = 0,
ScrollViewComponent = Reanimated.ScrollView,
snapToOffsets,
withKeyboardHeightPadding = true,
...rest
},
ref,
Expand Down Expand Up @@ -383,7 +386,7 @@ const KeyboardAwareScrollView = forwardRef<
onLayout={onScrollViewLayout}
>
{children}
<Reanimated.View style={view} />
{withKeyboardHeightPadding && <Reanimated.View style={view} />}
</ScrollViewComponent>
);
},
Expand Down