Skip to content

Commit

Permalink
🐛fix(RN-UI): animated input didn't watch if there was a value entered
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasWerey committed Jun 27, 2024
1 parent 85b28fe commit f98ca2e
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 f98ca2e

Please sign in to comment.