Fix Gif Select dialog search bar scrolling away (#8874)

* fix flatlist dialogs on web

* tweak gif select dialog, add style prop to textfield
This commit is contained in:
Samuel Newman
2025-08-25 19:37:12 +03:00
committed by GitHub
parent 7771b56a43
commit 27c591f031
4 changed files with 24 additions and 16 deletions
+3 -3
View File
@@ -193,7 +193,7 @@ export function Inner({
onInteractOutside={preventDefault} onInteractOutside={preventDefault}
onFocusOutside={preventDefault} onFocusOutside={preventDefault}
onDismiss={close} onDismiss={close}
style={{display: 'flex', flexDirection: 'column'}}> style={{height: '100%', display: 'flex', flexDirection: 'column'}}>
{header} {header}
<View style={[gtMobile ? a.p_2xl : a.p_xl, contentContainerStyle]}> <View style={[gtMobile ? a.p_2xl : a.p_xl, contentContainerStyle]}>
{children} {children}
@@ -227,10 +227,10 @@ export const InnerFlatList = React.forwardRef<
web({maxHeight: '80vh'}), web({maxHeight: '80vh'}),
webInnerStyle, webInnerStyle,
]} ]}
contentContainerStyle={[a.px_0, webInnerContentContainerStyle]}> contentContainerStyle={[a.h_full, a.px_0, webInnerContentContainerStyle]}>
<FlatList <FlatList
ref={ref} ref={ref}
style={[gtMobile ? a.px_2xl : a.px_xl, flatten(style)]} style={[a.h_full, gtMobile ? a.px_2xl : a.px_xl, flatten(style)]}
{...props} {...props}
/> />
</Inner> </Inner>
+3 -2
View File
@@ -5,7 +5,6 @@ import {
View, View,
type ViewStyle, type ViewStyle,
} from 'react-native' } from 'react-native'
import type React from 'react'
import {atoms as a, useTheme} from '#/alf' import {atoms as a, useTheme} from '#/alf'
import {Text} from '#/components/Typography' import {Text} from '#/components/Typography'
@@ -28,6 +27,8 @@ export function Header({
<View <View
onLayout={onLayout} onLayout={onLayout}
style={[ style={[
a.sticky,
a.top_0,
a.relative, a.relative,
a.w_full, a.w_full,
a.py_sm, a.py_sm,
@@ -61,7 +62,7 @@ export function HeaderText({
style?: StyleProp<TextStyle> style?: StyleProp<TextStyle>
}) { }) {
return ( return (
<Text style={[a.text_lg, a.text_center, a.font_bold, style]}> <Text style={[a.text_lg, a.text_center, a.font_heavy, style]}>
{children} {children}
</Text> </Text>
) )
+6 -8
View File
@@ -1,4 +1,4 @@
import React, { import {
useCallback, useCallback,
useImperativeHandle, useImperativeHandle,
useMemo, useMemo,
@@ -119,7 +119,7 @@ function GifList({
[onSelectGif], [onSelectGif],
) )
const onEndReached = React.useCallback(() => { const onEndReached = useCallback(() => {
if (isFetchingNextPage || !hasNextPage || error) return if (isFetchingNextPage || !hasNextPage || error) return
fetchNextPage() fetchNextPage()
}, [isFetchingNextPage, hasNextPage, error, fetchNextPage]) }, [isFetchingNextPage, hasNextPage, error, fetchNextPage])
@@ -172,7 +172,7 @@ function GifList({
</Button> </Button>
)} )}
<TextField.Root> <TextField.Root style={[!gtMobile && isWeb && a.flex_1]}>
<TextField.Icon icon={Search} /> <TextField.Icon icon={Search} />
<TextField.Input <TextField.Input
label={_(msg`Search GIFs`)} label={_(msg`Search GIFs`)}
@@ -206,11 +206,9 @@ function GifList({
renderItem={renderItem} renderItem={renderItem}
numColumns={gtMobile ? 3 : 2} numColumns={gtMobile ? 3 : 2}
columnWrapperStyle={[a.gap_sm]} columnWrapperStyle={[a.gap_sm]}
contentContainerStyle={[ contentContainerStyle={[native([a.px_xl, {minHeight: height}])]}
native([a.px_xl, {minHeight: height}]), webInnerStyle={[web({minHeight: '80vh'})]}
web(a.h_full_vh), webInnerContentContainerStyle={[web(a.pb_0)]}
]}
style={[web(a.h_full_vh)]}
ListHeaderComponent={ ListHeaderComponent={
<> <>
{listHeader} {listHeader}
+12 -3
View File
@@ -48,9 +48,11 @@ const Context = createContext<{
}) })
Context.displayName = 'TextFieldContext' Context.displayName = 'TextFieldContext'
export type RootProps = React.PropsWithChildren<{isInvalid?: boolean}> export type RootProps = React.PropsWithChildren<
{isInvalid?: boolean} & TextStyleProp
>
export function Root({children, isInvalid = false}: RootProps) { export function Root({children, isInvalid = false, style}: RootProps) {
const inputRef = useRef<TextInput>(null) const inputRef = useRef<TextInput>(null)
const { const {
state: hovered, state: hovered,
@@ -85,7 +87,14 @@ export function Root({children, isInvalid = false}: RootProps) {
return ( return (
<Context.Provider value={context}> <Context.Provider value={context}>
<View <View
style={[a.flex_row, a.align_center, a.relative, a.w_full, a.px_md]} style={[
a.flex_row,
a.align_center,
a.relative,
a.w_full,
a.px_md,
style,
]}
{...web({ {...web({
onClick: () => inputRef.current?.focus(), onClick: () => inputRef.current?.focus(),
onMouseOver: onHoverIn, onMouseOver: onHoverIn,