Skip to content

Commit

Permalink
fix: wrong dom attribute (#10602)
Browse files Browse the repository at this point in the history
  • Loading branch information
UncleBill authored and guanbinrui committed Aug 24, 2023
1 parent 4ad8788 commit 8817ecc
Showing 1 changed file with 35 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,40 @@ import { StyledInput } from '../StyledInput/index.js'
import { Icons } from '@masknet/icons'

export const PasswordField = memo(
forwardRef<{}, TextFieldProps & { show?: boolean; onClear?: () => void }>((props, ref) => {
const theme = useTheme()
const [showPassword, setShowPassword] = useState(false)
const { show = true, error, onClear } = props
return (
<StyledInput
{...props}
type={showPassword ? 'text' : 'password'}
ref={ref}
InputProps={{
endAdornment:
error && onClear ? (
<InputAdornment position="end" sx={{ paddingRight: 1.5 }}>
<IconButton onClick={onClear} edge="end" size="small">
<Icons.Close size={24} color={theme.palette.maskColor.danger} />
</IconButton>
</InputAdornment>
) : (
<InputAdornment position="end">
{show ? (
<IconButton
aria-label="toggle password visibility"
onClick={() => setShowPassword(!showPassword)}
onMouseDown={(event) => event.preventDefault()}
edge="end"
size="small">
{showPassword ? <Icons.EyeOff /> : <Icons.Eye />}
forwardRef<{}, TextFieldProps & { show?: boolean; onClear?: () => void }>(
({ show = true, onClear, ...rest }, ref) => {
const theme = useTheme()
const [showPassword, setShowPassword] = useState(false)
return (
<StyledInput
{...rest}
type={showPassword ? 'text' : 'password'}
ref={ref}
InputProps={{
endAdornment:
rest.error && onClear ? (
<InputAdornment position="end" sx={{ paddingRight: 1.5 }}>
<IconButton onClick={onClear} edge="end" size="small">
<Icons.Close size={24} color={theme.palette.maskColor.danger} />
</IconButton>
) : undefined}
</InputAdornment>
),
}}
/>
)
}),
</InputAdornment>
) : (
<InputAdornment position="end">
{show ? (
<IconButton
aria-label="toggle password visibility"
onClick={() => setShowPassword(!showPassword)}
onMouseDown={(event) => event.preventDefault()}
edge="end"
size="small">
{showPassword ? <Icons.EyeOff /> : <Icons.Eye />}
</IconButton>
) : undefined}
</InputAdornment>
),
}}
/>
)
},
),
)

0 comments on commit 8817ecc

Please sign in to comment.