Skip to content

Commit 0ee3e39

Browse files
author
Test
committed
🤖 fix: avoid nested virtualized lists in run settings
- Replace FlatList with simple mapped view inside RunSettingsSheet to prevent ScrollView nesting errors - Add capped height container while keeping separators and empty state messaging Generated with Change-Id: I53779b91607177dcce74d40c196be48ab9a8570c Signed-off-by: Test <test@example.com>
1 parent 06d2c9c commit 0ee3e39

File tree

1 file changed

+37
-34
lines changed

1 file changed

+37
-34
lines changed

apps/mobile/src/components/RunSettingsSheet.tsx

Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import type { JSX } from "react";
22
import { useMemo, useState, useEffect } from "react";
33
import {
4-
FlatList,
54
Modal,
65
Pressable,
76
ScrollView,
@@ -210,45 +209,46 @@ export function RunSettingsSheet(props: RunSettingsSheetProps): JSX.Element {
210209
</View>
211210
)}
212211

213-
<FlatList
214-
data={filteredModels}
215-
keyExtractor={(item) => item.id}
216-
nestedScrollEnabled
217-
style={{ maxHeight: 320 }}
218-
renderItem={({ item }) => (
219-
<Pressable
220-
onPress={() => handleSelectModel(item.id)}
221-
style={({ pressed }) => [
222-
styles.listItem,
223-
{
224-
backgroundColor: pressed
225-
? theme.colors.surfaceSecondary
226-
: theme.colors.background,
227-
},
228-
]}
229-
>
230-
<View style={{ flex: 1 }}>
231-
<ThemedText weight="semibold">{getModelDisplayName(item.id)}</ThemedText>
232-
<ThemedText variant="caption" style={{ color: theme.colors.foregroundMuted }}>
233-
{formatModelSummary(item.id)}
234-
</ThemedText>
235-
</View>
236-
{props.selectedModel === item.id && (
237-
<Ionicons name="checkmark-circle" size={20} color={theme.colors.accent} />
238-
)}
239-
</Pressable>
240-
)}
241-
ItemSeparatorComponent={() => (
242-
<View style={{ height: StyleSheet.hairlineWidth, backgroundColor: theme.colors.border }} />
243-
)}
244-
ListEmptyComponent={() => (
212+
<View style={styles.modelList}>
213+
{filteredModels.length === 0 ? (
245214
<View style={{ padding: 24 }}>
246215
<ThemedText variant="caption" style={{ textAlign: "center" }}>
247216
No models match "{query}"
248217
</ThemedText>
249218
</View>
219+
) : (
220+
filteredModels.map((item, index) => (
221+
<View key={item.id}>
222+
<Pressable
223+
onPress={() => handleSelectModel(item.id)}
224+
style={({ pressed }) => [
225+
styles.listItem,
226+
{
227+
backgroundColor: pressed
228+
? theme.colors.surfaceSecondary
229+
: theme.colors.background,
230+
},
231+
]}
232+
>
233+
<View style={{ flex: 1 }}>
234+
<ThemedText weight="semibold">{getModelDisplayName(item.id)}</ThemedText>
235+
<ThemedText variant="caption" style={{ color: theme.colors.foregroundMuted }}>
236+
{formatModelSummary(item.id)}
237+
</ThemedText>
238+
</View>
239+
{props.selectedModel === item.id && (
240+
<Ionicons name="checkmark-circle" size={20} color={theme.colors.accent} />
241+
)}
242+
</Pressable>
243+
{index < filteredModels.length - 1 ? (
244+
<View
245+
style={{ height: StyleSheet.hairlineWidth, backgroundColor: theme.colors.border }}
246+
/>
247+
) : null}
248+
</View>
249+
))
250250
)}
251-
/>
251+
</View>
252252
</SectionCard>
253253

254254
<SectionCard
@@ -391,6 +391,9 @@ const styles = StyleSheet.create({
391391
gap: 8,
392392
marginTop: 8,
393393
},
394+
modelList: {
395+
maxHeight: 320,
396+
},
394397
chip: {
395398
paddingVertical: 6,
396399
paddingHorizontal: 12,

0 commit comments

Comments
 (0)