Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,22 @@ interface PasswordBoxButtonProps {
onClick: (event: Readonly<React.MouseEvent<HTMLButtonElement>>) => void;
disabled: boolean;
isPasswordVisible: boolean;
testId?: string;
}

export const PasswordInputButton = ({
onClick,
disabled,
isPasswordVisible,
testId,
}: Readonly<PasswordBoxButtonProps>): JSX.Element => {
return (
<button
type="button"
className={cx.inputButton}
onClick={onClick}
disabled={disabled}
data-testid={testId}
>
{isPasswordVisible ? (
<CloseEye
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface PasswordInputProps extends Form.FormControlProps {
defaultIsPasswordVisible?: boolean;
containerClassName?: string;
containerStyle?: React.CSSProperties;
testId?: string;
}

export const PasswordInput = ({
Expand All @@ -35,6 +36,7 @@ export const PasswordInput = ({
onChange,
defaultIsPasswordVisible = false,
containerStyle,
testId,
}: Readonly<PasswordInputProps>): JSX.Element => {
const [isPasswordVisible, setIsPasswordVisible] = useState(
defaultIsPasswordVisible,
Expand Down Expand Up @@ -62,6 +64,7 @@ export const PasswordInput = ({
value={value}
onChange={onChange}
id={id}
data-testid={testId}
/>
</Form.Control>
<Form.Label
Expand All @@ -70,6 +73,7 @@ export const PasswordInput = ({
{label}
</Form.Label>
<PasswordInputButton
testId={testId && `${testId}-toggle`}
onClick={(event): void => {
event.preventDefault();
setIsPasswordVisible(!isPasswordVisible);
Expand Down