Skip to content

Commit

Permalink
fix: only check hidden if reveal is true, to correctly handle `re…
Browse files Browse the repository at this point in the history
…veal` changes
  • Loading branch information
thebengeu committed Feb 10, 2022
1 parent 6dc46ee commit a854563
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/components/Input/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function Input({
...props
}: Props) {
const [copyLabel, setCopyLabel] = useState('Copy')
const [hidden, setHidden] = useState(reveal)
const [hidden, setHidden] = useState(true)

// if `type` is not assigned, default to text input
if (!type) {
Expand Down Expand Up @@ -125,7 +125,7 @@ function Input({
placeholder={placeholder}
ref={inputRef}
type={type}
value={hidden ? hiddenPlaceholder : value}
value={reveal && hidden ? hiddenPlaceholder : value}
className={inputClasses.join(' ')}
{...props}
/>
Expand All @@ -136,7 +136,7 @@ function Input({
size={1}
>
{error && <InputErrorIcon size={size} />}
{copy && !hidden ? (
{copy && !(reveal && hidden) ? (
<Button
size="tiny"
type="default"
Expand All @@ -146,7 +146,7 @@ function Input({
{copyLabel}
</Button>
) : null}
{hidden && reveal ? (
{reveal && hidden ? (
<Button size="tiny" type="default" onClick={onReveal}>
Reveal
</Button>
Expand Down

0 comments on commit a854563

Please sign in to comment.