Skip to content

Commit

Permalink
fix(react): TextField prefix/suffix first render transition (#153)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonambas authored Sep 19, 2023
1 parent a047506 commit 7ba9923
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions packages/react/src/text-field/TextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ const inputStyles = cva({
background: 'transparent',
fontSize: '3',
paddingX: '3',
transition: '0.15s',
transitionDuration: '0.15s',
transitionProperty: 'background, border',
outline: 'none',
color: 'gray12',
'&:hover:not(:focus)': {
Expand Down Expand Up @@ -116,8 +117,8 @@ const TextField = forwardRef<HTMLInputElement, TextFieldProps>(

useEffect(() => {
const styles: HTMLAttributes<'input'>['style'] = {
paddingLeft: undefined,
paddingRight: undefined
paddingLeft: prefix ? `calc(1rem + 1ch)` : undefined,
paddingRight: suffix ? `calc(1rem + 1ch)` : undefined
};

if (prefixRef.current) {
Expand All @@ -129,7 +130,7 @@ const TextField = forwardRef<HTMLInputElement, TextFieldProps>(
}

setPadding(styles);
}, [prefixRef, suffixRef]);
}, [prefix, suffix, prefixRef, suffixRef]);

return (
<div className={containerStyles}>
Expand Down

0 comments on commit 7ba9923

Please sign in to comment.