Skip to content

Commit 0b7977a

Browse files
authored
fix: respect topInset on bottom sheet once again (#3606)
## 🎯 Goal This PR addresses a regression with our `AttachmentPicker` component which was done in order to fix accessibility issues. Namely, since we calculate the `topInset` for our `BottomSheet` in order to make it properly orderable by screen readers, the value for the global `topInset` was omitted. This is wrong, because then the calculations are very wrong particularly in the cases of having native modals (i.e `react-navigation/native-stack` or `expo-router`) whose height we need to take into account, similarly to how we do it for `keyboardVerticalOffset`. ## 🛠 Implementation details <!-- Provide a description of the implementation --> ## 🎨 UI Changes <!-- Add relevant screenshots --> <details> <summary>iOS</summary> <table> <thead> <tr> <td>Before</td> <td>After</td> </tr> </thead> <tbody> <tr> <td> <!--<img src="" /> --> </td> <td> <!--<img src="" /> --> </td> </tr> </tbody> </table> </details> <details> <summary>Android</summary> <table> <thead> <tr> <td>Before</td> <td>After</td> </tr> </thead> <tbody> <tr> <td> <!--<img src="" /> --> </td> <td> <!--<img src="" /> --> </td> </tr> </tbody> </table> </details> ## 🧪 Testing <!-- Explain how this change can be tested (or why it can't be tested) --> ## ☑️ Checklist - [ ] I have signed the [Stream CLA](https://docs.google.com/forms/d/e/1FAIpQLScFKsKkAJI7mhCr7K9rEIOpqIDThrWxuvxnwUq2XkHyG154vQ/viewform) (required) - [ ] PR targets the `develop` branch - [ ] Documentation is updated - [ ] New code is tested in main example apps, including all possible scenarios - [ ] SampleApp iOS and Android - [ ] Expo iOS and Android
1 parent 2dedcd6 commit 0b7977a

4 files changed

Lines changed: 5 additions & 2 deletions

File tree

examples/ExpoMessaging/app/channel/[cid]/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ export default function ChannelScreen() {
7373
channel={channel}
7474
onPressMessage={onPressMessage}
7575
keyboardVerticalOffset={headerHeight}
76+
topInset={headerHeight}
7677
thread={thread}
7778
>
7879
<MessageList

examples/ExpoMessaging/app/channel/[cid]/thread/[cid]/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export default function ThreadScreen() {
1919
audioRecordingEnabled={true}
2020
channel={channel}
2121
keyboardVerticalOffset={Platform.OS === 'ios' ? headerHeight : undefined}
22+
topInset={headerHeight}
2223
thread={thread}
2324
threadList
2425
>

package/src/components/AttachmentPicker/AttachmentPicker.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export const AttachmentPicker = () => {
3939
attachmentPickerBottomSheetHeight,
4040
bottomSheetRef: ref,
4141
bottomInset,
42+
topInset,
4243
disableAttachmentPicker,
4344
} = useAttachmentPickerContext();
4445
const { AttachmentPickerContent, AttachmentPickerSelectionBar } = useComponentsContext();
@@ -94,7 +95,7 @@ export const AttachmentPicker = () => {
9495
const initialSnapPoint = attachmentPickerBottomSheetHeight;
9596
const pickerTopInset = Math.max(
9697
0,
97-
windowHeight - attachmentPickerBottomSheetHeight - bottomInset,
98+
windowHeight - topInset - attachmentPickerBottomSheetHeight - bottomInset,
9899
);
99100

100101
/**

package/src/components/Channel/Channel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =
496496
thread: threadFromProps,
497497
threadList,
498498
threadMessages,
499-
topInset,
499+
topInset = 0,
500500
isOnline,
501501
maximumMessageLimit,
502502
initializeOnMount = true,

0 commit comments

Comments
 (0)