Skip to content

Commit

Permalink
fix: passing external on layout (#4204)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukewalczak authored Nov 27, 2023
1 parent 27e8234 commit 6ee89ee
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/components/TextInput/TextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ const TextInput = forwardRef<TextInputHandles, Props>(
onBlur={handleBlur}
onChangeText={handleChangeText}
onLayoutAnimatedText={handleLayoutAnimatedText}
onLayout={handleInputContainerLayout}
onInputLayout={handleInputContainerLayout}
onLabelTextLayout={handleLabelTextLayout}
onLeftAffixLayoutChange={onLeftAffixLayoutChange}
onRightAffixLayoutChange={onRightAffixLayoutChange}
Expand Down Expand Up @@ -553,7 +553,7 @@ const TextInput = forwardRef<TextInputHandles, Props>(
onFocus={handleFocus}
forceFocus={forceFocus}
onBlur={handleBlur}
onLayout={handleInputContainerLayout}
onInputLayout={handleInputContainerLayout}
onChangeText={handleChangeText}
onLayoutAnimatedText={handleLayoutAnimatedText}
onLabelTextLayout={handleLabelTextLayout}
Expand Down
4 changes: 2 additions & 2 deletions src/components/TextInput/TextInputFlat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const TextInputFlat = ({
onLabelTextLayout,
onLeftAffixLayoutChange,
onRightAffixLayoutChange,
onLayout,
onInputLayout,
left,
right,
placeholderTextColor,
Expand Down Expand Up @@ -343,7 +343,7 @@ const TextInputFlat = ({
theme={theme}
/>
<View
onLayout={onLayout}
onLayout={onInputLayout}
style={[
styles.labelContainer,
{
Expand Down
12 changes: 11 additions & 1 deletion src/components/TextInput/TextInputOutlined.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
Platform,
TextStyle,
ColorValue,
LayoutChangeEvent,
} from 'react-native';

import { Outline } from './Addons/Outline';
Expand Down Expand Up @@ -68,6 +69,7 @@ const TextInputOutlined = ({
onLabelTextLayout,
onLeftAffixLayoutChange,
onRightAffixLayoutChange,
onInputLayout,
onLayout,
left,
right,
Expand Down Expand Up @@ -249,6 +251,14 @@ const TextInputOutlined = ({
isV3,
};

const onLayoutChange = React.useCallback(
(e: LayoutChangeEvent) => {
onInputLayout(e);
onLayout?.(e);
},
[onLayout, onInputLayout]
);

const minHeight = (height ||
(dense ? MIN_DENSE_HEIGHT_OUTLINED : MIN_HEIGHT)) as number;

Expand Down Expand Up @@ -364,7 +374,7 @@ const TextInputOutlined = ({
{render?.({
...rest,
ref: innerRef,
onLayout,
onLayout: onLayoutChange,
onChangeText,
placeholder: label ? parentState.placeholder : rest.placeholder,
editable: !disabled && editable,
Expand Down
1 change: 1 addition & 0 deletions src/components/TextInput/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export type ChildTextInputProps = {
onBlur?: (args: any) => void;
forceFocus: () => void;
onChangeText?: (value: string) => void;
onInputLayout: (event: LayoutChangeEvent) => void;
onLayoutAnimatedText: (args: any) => void;
onLabelTextLayout: (event: NativeSyntheticEvent<TextLayoutEventData>) => void;
onLeftAffixLayoutChange: (event: LayoutChangeEvent) => void;
Expand Down

0 comments on commit 6ee89ee

Please sign in to comment.