Skip to content

Commit

Permalink
Merge pull request #7215 from LedgerHQ/fix/LIVE-12654
Browse files Browse the repository at this point in the history
🐛fix(RN-UI): animated input didn't watch if there was a value entered
  • Loading branch information
LucasWerey authored Jun 28, 2024
2 parents 76becbb + f98ca2e commit 62701c5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/spicy-waves-wave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ledgerhq/native-ui": patch
---

input animation triggers if there is any value entered
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,16 @@ const LineCutout = styled(Flex)<LineCutoutProps>`
type AnimatedNotchedLabelProps = {
placeholder: string;
inputStatus: InputStatus;
value: string;
};

export const AnimatedNotchedLabel = ({ placeholder, inputStatus }: AnimatedNotchedLabelProps) => {
export const AnimatedNotchedLabel = ({
placeholder,
inputStatus,
value,
}: AnimatedNotchedLabelProps) => {
const [labelWidth, setLabelWidth] = useState(0);
const notched = inputStatus !== "default";
const notched = inputStatus !== "default" || value.length > 0;

const labelTop = useSharedValue(notched ? labelFinalPositions.top : labelInitialPositions.top);
const labelLeft = useSharedValue(notched ? labelFinalPositions.left : labelInitialPositions.left);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,15 @@ const AnimatedInput = (

return (
<InputContainer status={inputStatus} style={style}>
{placeholder && <AnimatedNotchedLabel placeholder={placeholder} inputStatus={inputStatus} />}
{placeholder && (
<AnimatedNotchedLabel placeholder={placeholder} inputStatus={inputStatus} value={value} />
)}
<BaseInput
ref={ref}
onFocus={onFocus}
onBlur={onBlur}
error={error}
value={value as string}
value={value}
color={theme ? inputTextColor[inputStatus]({ theme }) : "neutral.c100"}
inputContainerStyle={{
backgroundColor: "none",
Expand Down

0 comments on commit 62701c5

Please sign in to comment.