Skip to content

Commit

Permalink
[material-ui][Text Field] when click password visibility button, text…
Browse files Browse the repository at this point in the history
… caret position change to very front. (#42595)
  • Loading branch information
appleSimple committed Jun 26, 2024
1 parent 2888995 commit 4780aeb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions docs/data/material/components/text-fields/InputAdornments.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ export default function InputAdornments() {
event.preventDefault();
};

const handleMouseUpPassword = (event) => {
event.preventDefault();
};

return (
<Box sx={{ display: 'flex', flexWrap: 'wrap' }}>
<div>
Expand Down Expand Up @@ -56,6 +60,7 @@ export default function InputAdornments() {
aria-label="toggle password visibility"
onClick={handleClickShowPassword}
onMouseDown={handleMouseDownPassword}
onMouseUp={handleMouseUpPassword}
edge="end"
>
{showPassword ? <VisibilityOff /> : <Visibility />}
Expand Down Expand Up @@ -108,6 +113,7 @@ export default function InputAdornments() {
aria-label="toggle password visibility"
onClick={handleClickShowPassword}
onMouseDown={handleMouseDownPassword}
onMouseUp={handleMouseUpPassword}
edge="end"
>
{showPassword ? <VisibilityOff /> : <Visibility />}
Expand Down Expand Up @@ -158,6 +164,7 @@ export default function InputAdornments() {
aria-label="toggle password visibility"
onClick={handleClickShowPassword}
onMouseDown={handleMouseDownPassword}
onMouseUp={handleMouseUpPassword}
>
{showPassword ? <VisibilityOff /> : <Visibility />}
</IconButton>
Expand Down
7 changes: 7 additions & 0 deletions docs/data/material/components/text-fields/InputAdornments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ export default function InputAdornments() {
event.preventDefault();
};

const handleMouseUpPassword = (event: React.MouseEvent<HTMLButtonElement>) => {
event.preventDefault();
};

return (
<Box sx={{ display: 'flex', flexWrap: 'wrap' }}>
<div>
Expand Down Expand Up @@ -56,6 +60,7 @@ export default function InputAdornments() {
aria-label="toggle password visibility"
onClick={handleClickShowPassword}
onMouseDown={handleMouseDownPassword}
onMouseUp={handleMouseUpPassword}
edge="end"
>
{showPassword ? <VisibilityOff /> : <Visibility />}
Expand Down Expand Up @@ -108,6 +113,7 @@ export default function InputAdornments() {
aria-label="toggle password visibility"
onClick={handleClickShowPassword}
onMouseDown={handleMouseDownPassword}
onMouseUp={handleMouseUpPassword}
edge="end"
>
{showPassword ? <VisibilityOff /> : <Visibility />}
Expand Down Expand Up @@ -158,6 +164,7 @@ export default function InputAdornments() {
aria-label="toggle password visibility"
onClick={handleClickShowPassword}
onMouseDown={handleMouseDownPassword}
onMouseUp={handleMouseUpPassword}
>
{showPassword ? <VisibilityOff /> : <Visibility />}
</IconButton>
Expand Down

0 comments on commit 4780aeb

Please sign in to comment.