Skip to content

Commit

Permalink
fix: unfocused TextInput label disappears on new architecture (#3776) (
Browse files Browse the repository at this point in the history
  • Loading branch information
osman-turan authored Sep 18, 2023
1 parent 02e9fec commit 9d802f6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
9 changes: 6 additions & 3 deletions src/components/TextInput/TextInputFlat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,14 @@ const TextInputFlat = ({
const baseLabelTranslateY =
-labelHalfHeight - (topPosition + MINIMIZED_LABEL_Y_OFFSET);

const { current: placeholderOpacityAnims } = React.useRef([
new Animated.Value(0),
new Animated.Value(1),
]);

const placeholderOpacity = hasActiveOutline
? parentState.labeled
: parentState.labelLayout.measured
? 1
: 0;
: placeholderOpacityAnims[parentState.labelLayout.measured ? 1 : 0];

const minHeight =
height ||
Expand Down
10 changes: 7 additions & 3 deletions src/components/TextInput/TextInputOutlined.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from 'react';
import {
Animated,
View,
TextInput as NativeTextInput,
StyleSheet,
Expand Down Expand Up @@ -175,11 +176,14 @@ const TextInputOutlined = ({
const baseLabelTranslateY =
-labelHalfHeight - (topPosition + OUTLINE_MINIMIZED_LABEL_Y_OFFSET);

const { current: placeholderOpacityAnims } = React.useRef([
new Animated.Value(0),
new Animated.Value(1),
]);

const placeholderOpacity = hasActiveOutline
? parentState.labeled
: parentState.labelLayout.measured
? 1
: 0;
: placeholderOpacityAnims[parentState.labelLayout.measured ? 1 : 0];

const placeholderStyle = {
position: 'absolute',
Expand Down

0 comments on commit 9d802f6

Please sign in to comment.