fix: visibility toggle for new password disabled on edit profile
This commit is contained in:
@@ -73,7 +73,9 @@ export default function FormContent() {
|
|||||||
</Body>
|
</Body>
|
||||||
</header>
|
</header>
|
||||||
<Input label={currentPassword} name="password" type="password" />
|
<Input label={currentPassword} name="password" type="password" />
|
||||||
<NewPassword />
|
{/* visibilityToggleable set to false as feature is done for signup first */}
|
||||||
|
{/* likely we can remove the prop altogether once signup launches */}
|
||||||
|
<NewPassword visibilityToggleable={false} />
|
||||||
<Input
|
<Input
|
||||||
label={retypeNewPassword}
|
label={retypeNewPassword}
|
||||||
name="retypeNewPassword"
|
name="retypeNewPassword"
|
||||||
|
|||||||
@@ -30,10 +30,11 @@ export default function NewPassword({
|
|||||||
placeholder = "",
|
placeholder = "",
|
||||||
registerOptions = {},
|
registerOptions = {},
|
||||||
label,
|
label,
|
||||||
|
visibilityToggleable = true,
|
||||||
}: NewPasswordProps) {
|
}: NewPasswordProps) {
|
||||||
const { control } = useFormContext()
|
const { control } = useFormContext()
|
||||||
const intl = useIntl()
|
const intl = useIntl()
|
||||||
const [isPasswordVisible, setPasswordVisible] = useState(false)
|
const [isPasswordVisible, setIsPasswordVisible] = useState(false)
|
||||||
|
|
||||||
function getErrorMessage(key: PasswordValidatorKey) {
|
function getErrorMessage(key: PasswordValidatorKey) {
|
||||||
switch (key) {
|
switch (key) {
|
||||||
@@ -69,7 +70,9 @@ export default function NewPassword({
|
|||||||
onChange={field.onChange}
|
onChange={field.onChange}
|
||||||
validationBehavior="aria"
|
validationBehavior="aria"
|
||||||
value={field.value}
|
value={field.value}
|
||||||
type={isPasswordVisible ? "text" : "password"}
|
type={
|
||||||
|
visibilityToggleable && isPasswordVisible ? "text" : "password"
|
||||||
|
}
|
||||||
>
|
>
|
||||||
<div className={styles.inputWrapper}>
|
<div className={styles.inputWrapper}>
|
||||||
<AriaInputWithLabel
|
<AriaInputWithLabel
|
||||||
@@ -78,18 +81,24 @@ export default function NewPassword({
|
|||||||
id={field.name}
|
id={field.name}
|
||||||
label={intl.formatMessage({ id: "New password" })}
|
label={intl.formatMessage({ id: "New password" })}
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
type={isPasswordVisible ? "text" : "password"}
|
type={
|
||||||
|
visibilityToggleable && isPasswordVisible
|
||||||
|
? "text"
|
||||||
|
: "password"
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
<Button
|
{visibilityToggleable ? (
|
||||||
className={styles.eyeIcon}
|
<Button
|
||||||
type="button"
|
className={styles.eyeIcon}
|
||||||
variant="icon"
|
type="button"
|
||||||
size="small"
|
variant="icon"
|
||||||
intent="tertiary"
|
size="small"
|
||||||
onClick={() => setPasswordVisible(!isPasswordVisible)}
|
intent="tertiary"
|
||||||
>
|
onClick={() => setIsPasswordVisible((value) => !value)}
|
||||||
{isPasswordVisible ? <EyeHideIcon /> : <EyeShowIcon />}
|
>
|
||||||
</Button>
|
{isPasswordVisible ? <EyeHideIcon /> : <EyeShowIcon />}
|
||||||
|
</Button>
|
||||||
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
{field.value ? (
|
{field.value ? (
|
||||||
<div className={styles.errors}>
|
<div className={styles.errors}>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ export interface NewPasswordProps
|
|||||||
extends React.InputHTMLAttributes<HTMLInputElement> {
|
extends React.InputHTMLAttributes<HTMLInputElement> {
|
||||||
label?: string
|
label?: string
|
||||||
registerOptions?: RegisterOptions
|
registerOptions?: RegisterOptions
|
||||||
|
visibilityToggleable?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IconProps {
|
export interface IconProps {
|
||||||
|
|||||||
Reference in New Issue
Block a user