Skip to content

Commit 6ee89ee

Browse files
authored
fix: passing external on layout (#4204)
1 parent 27e8234 commit 6ee89ee

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

src/components/TextInput/TextInput.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ const TextInput = forwardRef<TextInputHandles, Props>(
514514
onBlur={handleBlur}
515515
onChangeText={handleChangeText}
516516
onLayoutAnimatedText={handleLayoutAnimatedText}
517-
onLayout={handleInputContainerLayout}
517+
onInputLayout={handleInputContainerLayout}
518518
onLabelTextLayout={handleLabelTextLayout}
519519
onLeftAffixLayoutChange={onLeftAffixLayoutChange}
520520
onRightAffixLayoutChange={onRightAffixLayoutChange}
@@ -553,7 +553,7 @@ const TextInput = forwardRef<TextInputHandles, Props>(
553553
onFocus={handleFocus}
554554
forceFocus={forceFocus}
555555
onBlur={handleBlur}
556-
onLayout={handleInputContainerLayout}
556+
onInputLayout={handleInputContainerLayout}
557557
onChangeText={handleChangeText}
558558
onLayoutAnimatedText={handleLayoutAnimatedText}
559559
onLabelTextLayout={handleLabelTextLayout}

src/components/TextInput/TextInputFlat.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ const TextInputFlat = ({
6868
onLabelTextLayout,
6969
onLeftAffixLayoutChange,
7070
onRightAffixLayoutChange,
71-
onLayout,
71+
onInputLayout,
7272
left,
7373
right,
7474
placeholderTextColor,
@@ -343,7 +343,7 @@ const TextInputFlat = ({
343343
theme={theme}
344344
/>
345345
<View
346-
onLayout={onLayout}
346+
onLayout={onInputLayout}
347347
style={[
348348
styles.labelContainer,
349349
{

src/components/TextInput/TextInputOutlined.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
Platform,
99
TextStyle,
1010
ColorValue,
11+
LayoutChangeEvent,
1112
} from 'react-native';
1213

1314
import { Outline } from './Addons/Outline';
@@ -68,6 +69,7 @@ const TextInputOutlined = ({
6869
onLabelTextLayout,
6970
onLeftAffixLayoutChange,
7071
onRightAffixLayoutChange,
72+
onInputLayout,
7173
onLayout,
7274
left,
7375
right,
@@ -249,6 +251,14 @@ const TextInputOutlined = ({
249251
isV3,
250252
};
251253

254+
const onLayoutChange = React.useCallback(
255+
(e: LayoutChangeEvent) => {
256+
onInputLayout(e);
257+
onLayout?.(e);
258+
},
259+
[onLayout, onInputLayout]
260+
);
261+
252262
const minHeight = (height ||
253263
(dense ? MIN_DENSE_HEIGHT_OUTLINED : MIN_HEIGHT)) as number;
254264

@@ -364,7 +374,7 @@ const TextInputOutlined = ({
364374
{render?.({
365375
...rest,
366376
ref: innerRef,
367-
onLayout,
377+
onLayout: onLayoutChange,
368378
onChangeText,
369379
placeholder: label ? parentState.placeholder : rest.placeholder,
370380
editable: !disabled && editable,

src/components/TextInput/types.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ export type ChildTextInputProps = {
8686
onBlur?: (args: any) => void;
8787
forceFocus: () => void;
8888
onChangeText?: (value: string) => void;
89+
onInputLayout: (event: LayoutChangeEvent) => void;
8990
onLayoutAnimatedText: (args: any) => void;
9091
onLabelTextLayout: (event: NativeSyntheticEvent<TextLayoutEventData>) => void;
9192
onLeftAffixLayoutChange: (event: LayoutChangeEvent) => void;

0 commit comments

Comments
 (0)