Skip to content

Commit 6f37645

Browse files
authored
fix: truncated content in Flash/Legend list in KeyboardChatScrollView example (#1326)
## 📜 Description Fixed Flash/Legend content partial obscure in `KeyboardChatScrollView`. ## 💡 Motivation and Context Somehow skipped this during initial implementation. Fixing it now 👀 Closes #1323 ## 📢 Changelog <!-- High level overview of important changes --> <!-- For example: fixed status bar manipulation; added new types declarations; --> <!-- If your changes don't affect one of platform/language below - then remove this platform/language --> ### JS - specify `contentContainerStyle` on `list` level (not underlying `ScrollView`) ## 🤔 How Has This Been Tested? Tested manually on iPhone 17 Pro. ## 📸 Screenshots (if appropriate): |Before|After| |-------|-----| |<img width="1206" height="2622" alt="image" src="https://github.com/user-attachments/assets/1260f765-998b-4167-94b6-fd67becd3061" />|<img width="1206" height="2622" alt="image" src="https://github.com/user-attachments/assets/a2005e3e-4dcc-4bdb-a2d9-66b93e91e933" />| ## 📝 Checklist - [x] CI successfully passed - [x] I added new mocks and corresponding unit-tests if library API was changed
1 parent 7ece2d8 commit 6f37645

6 files changed

Lines changed: 41 additions & 22 deletions

File tree

FabricExample/src/screens/Examples/KeyboardChatScrollView/VirtualizedListScrollView.tsx

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { forwardRef, useCallback, useMemo, useState } from "react";
1+
import React, { forwardRef, useCallback, useState } from "react";
22
import {
33
type LayoutChangeEvent,
44
type ScrollViewProps,
@@ -9,7 +9,11 @@ import { KeyboardChatScrollView } from "react-native-keyboard-controller";
99
import { useSafeAreaInsets } from "react-native-safe-area-context";
1010

1111
import { useChatConfigStore } from "./store";
12-
import { MARGIN, TEXT_INPUT_HEIGHT } from "./styles";
12+
import {
13+
MARGIN,
14+
contentContainerStyle,
15+
invertedContentContainerStyle,
16+
} from "./styles";
1317

1418
export type VirtualizedListScrollViewRef = React.ElementRef<
1519
typeof KeyboardChatScrollView
@@ -25,14 +29,6 @@ const VirtualizedListScrollView = forwardRef<
2529

2630
const { inverted, freeze, mode, keyboardLiftBehavior } = useChatConfigStore();
2731

28-
const contentContainerStyle = useMemo(
29-
() => ({ paddingBottom: TEXT_INPUT_HEIGHT + MARGIN }),
30-
[],
31-
);
32-
const invertedContentContainerStyle = useMemo(
33-
() => ({ paddingTop: TEXT_INPUT_HEIGHT + MARGIN }),
34-
[],
35-
);
3632
// on new arch only FlatList supports `inverted` prop
3733
const isInvertedSupported = inverted && mode === "flat" ? inverted : false;
3834
const onLayout = useCallback(

FabricExample/src/screens/Examples/KeyboardChatScrollView/index.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ import BlurView from "../../../components/BlurView";
2929
import Message from "./components/Message";
3030
import ConfigSheet from "./config";
3131
import { useChatConfigStore } from "./store";
32-
import styles, { MARGIN, TEXT_INPUT_HEIGHT } from "./styles";
32+
import styles, {
33+
MARGIN,
34+
TEXT_INPUT_HEIGHT,
35+
contentContainerStyle,
36+
} from "./styles";
3337
import VirtualizedListScrollView, {
3438
type VirtualizedListScrollViewRef,
3539
} from "./VirtualizedListScrollView";
@@ -102,6 +106,7 @@ function KeyboardChatScrollViewPlayground() {
102106
<LegendList
103107
ref={legendRef}
104108
alignItemsAtEnd={inverted}
109+
contentContainerStyle={contentContainerStyle}
105110
data={messages}
106111
initialScrollAtEnd={inverted}
107112
keyExtractor={(item) => item.text}
@@ -112,6 +117,7 @@ function KeyboardChatScrollViewPlayground() {
112117
{mode === "flash" && (
113118
<FlashList
114119
ref={flashRef}
120+
contentContainerStyle={contentContainerStyle}
115121
data={messages}
116122
keyExtractor={(item) => item.text}
117123
maintainVisibleContentPosition={{

FabricExample/src/screens/Examples/KeyboardChatScrollView/styles.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,9 @@ export default StyleSheet.create({
4242
height: 20,
4343
},
4444
});
45+
export const contentContainerStyle = {
46+
paddingBottom: TEXT_INPUT_HEIGHT + MARGIN,
47+
};
48+
export const invertedContentContainerStyle = {
49+
paddingTop: TEXT_INPUT_HEIGHT + MARGIN,
50+
};

example/src/screens/Examples/KeyboardChatScrollView/VirtualizedListScrollView.tsx

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { forwardRef, useCallback, useMemo, useState } from "react";
1+
import React, { forwardRef, useCallback, useState } from "react";
22
import {
33
type LayoutChangeEvent,
44
type ScrollViewProps,
@@ -9,7 +9,11 @@ import { KeyboardChatScrollView } from "react-native-keyboard-controller";
99
import { useSafeAreaInsets } from "react-native-safe-area-context";
1010

1111
import { useChatConfigStore } from "./store";
12-
import { MARGIN, TEXT_INPUT_HEIGHT } from "./styles";
12+
import {
13+
MARGIN,
14+
contentContainerStyle,
15+
invertedContentContainerStyle,
16+
} from "./styles";
1317

1418
export type VirtualizedListScrollViewRef = React.ElementRef<
1519
typeof KeyboardChatScrollView
@@ -25,14 +29,6 @@ const VirtualizedListScrollView = forwardRef<
2529

2630
const { inverted, freeze, mode, keyboardLiftBehavior } = useChatConfigStore();
2731

28-
const contentContainerStyle = useMemo(
29-
() => ({ paddingBottom: TEXT_INPUT_HEIGHT + MARGIN }),
30-
[],
31-
);
32-
const invertedContentContainerStyle = useMemo(
33-
() => ({ paddingTop: TEXT_INPUT_HEIGHT + MARGIN }),
34-
[],
35-
);
3632
// on old arch only FlatList and FlashList supports `inverted` prop
3733
const isInvertedSupported =
3834
inverted && (mode === "flat" || mode === "flash") ? inverted : false;

example/src/screens/Examples/KeyboardChatScrollView/index.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@ import BlurView from "../../../components/BlurView";
2929
import Message from "./components/Message";
3030
import ConfigSheet from "./config";
3131
import { useChatConfigStore } from "./store";
32-
import styles, { MARGIN, TEXT_INPUT_HEIGHT } from "./styles";
32+
import styles, {
33+
MARGIN,
34+
TEXT_INPUT_HEIGHT,
35+
contentContainerStyle,
36+
invertedContentContainerStyle,
37+
} from "./styles";
3338
import VirtualizedListScrollView, {
3439
type VirtualizedListScrollViewRef,
3540
} from "./VirtualizedListScrollView";
@@ -102,6 +107,7 @@ function KeyboardChatScrollViewPlayground() {
102107
<LegendList
103108
ref={legendRef}
104109
alignItemsAtEnd={inverted}
110+
contentContainerStyle={contentContainerStyle}
105111
data={messages}
106112
keyExtractor={(item) => item.text}
107113
renderItem={({ item }) => <Message {...item} />}
@@ -111,6 +117,9 @@ function KeyboardChatScrollViewPlayground() {
111117
{mode === "flash" && (
112118
<FlashList
113119
ref={flashRef}
120+
contentContainerStyle={
121+
inverted ? invertedContentContainerStyle : contentContainerStyle
122+
}
114123
data={inverted ? reversedMessages : messages}
115124
inverted={inverted}
116125
keyExtractor={(item) => item.text}

example/src/screens/Examples/KeyboardChatScrollView/styles.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,9 @@ export default StyleSheet.create({
4242
height: 20,
4343
},
4444
});
45+
export const contentContainerStyle = {
46+
paddingBottom: TEXT_INPUT_HEIGHT + MARGIN,
47+
};
48+
export const invertedContentContainerStyle = {
49+
paddingTop: TEXT_INPUT_HEIGHT + MARGIN,
50+
};

0 commit comments

Comments
 (0)