Skip to content
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
3 changes: 2 additions & 1 deletion src/components/BottomSheetWithSearchInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ const BottomSheetWithSearchInput = ({
animationConfigs={animationConfigs}
snapPoints={['80%']}
enableDynamicSizing={false}
bottomInset={insets.bottom}
handleIndicatorStyle={bottomSheetStyles.handleIndicator}
handleStyle={[bottomSheetStyles.handle, { backgroundColor: colors.card }]}
keyboardBehavior="extend"
Expand All @@ -161,7 +162,7 @@ const BottomSheetWithSearchInput = ({
ItemSeparatorComponent={Separator}
keyboardDismissMode="on-drag"
keyboardShouldPersistTaps="handled"
contentContainerStyle={{ paddingBottom: insets.bottom, backgroundColor: colors.card }}
contentContainerStyle={{ backgroundColor: colors.card }}
ListHeaderComponent={listHeader}
stickyHeaderIndices={[0]}
renderItem={({ item }) => (
Expand Down
30 changes: 30 additions & 0 deletions src/components/__tests__/BottomSheetWithSearchInput.test.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import React from 'react'
import { Keyboard } from 'react-native'

import BottomSheet from '@gorhom/bottom-sheet'
import { describe, expect, jest, test } from '@jest/globals'
import { NavigationContainer } from '@react-navigation/native'
import { fireEvent, render } from '@testing-library/react-native'
import { SafeAreaProvider } from 'react-native-safe-area-context'

import BottomSheetWithSearchInput from '../BottomSheetWithSearchInput'

Expand Down Expand Up @@ -43,6 +45,34 @@ describe('BottomSheetWithSearchInput', () => {
const { toJSON } = renderComponent({ selectedKey: 'nl' })
expect(toJSON()).toMatchSnapshot()
})

test('Passes the safe area bottom inset to the bottom sheet when insets are present', () => {
const { UNSAFE_getByType } = render(
<NavigationContainer>
<SafeAreaProvider
initialMetrics={{
frame: { x: 0, y: 0, width: 0, height: 0 },
insets: {
left: 0,
top: 59,
right: 0,
bottom: 34,
},
}}
>
<BottomSheetWithSearchInput
inputFieldPlaceholder="Start typing..."
data={DATA}
sectionTitle="Countries"
onClose={jest.fn()}
onPress={jest.fn()}
/>
</SafeAreaProvider>
</NavigationContainer>,
)

expect(UNSAFE_getByType(BottomSheet).props.bottomInset).toBe(34)
})
})

describe('Interaction', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ exports[`BottomSheetWithSearchInput Rendering Initial state 1`] = `
contentContainerStyle={
{
"backgroundColor": "rgb(255, 255, 255)",
"paddingBottom": 0,
}
}
data={
Expand Down Expand Up @@ -682,7 +681,6 @@ exports[`BottomSheetWithSearchInput Rendering With selected item 1`] = `
contentContainerStyle={
{
"backgroundColor": "rgb(255, 255, 255)",
"paddingBottom": 0,
}
}
data={
Expand Down