Skip to content

Commit

Permalink
fix: toggle password
Browse files Browse the repository at this point in the history
  • Loading branch information
Benehiko committed Oct 13, 2023
1 parent caf283b commit c892eca
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/assets/passwordInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ document.getElementsByName("password").forEach((p) => {
visibilityToggle.dataset.checked =
visibilityToggle.dataset.checked === "true" ? "false" : "true"
})
visibilityToggle.addEventListener("keydown", function () {
togglePassword(p)
visibilityToggle.dataset.checked =
visibilityToggle.dataset.checked === "true" ? "false" : "true"
visibilityToggle.addEventListener("keydown", function (e) {
if (e.key === "Enter" || e.key === " ") {
togglePassword(p)
visibilityToggle.dataset.checked =
visibilityToggle.dataset.checked === "true" ? "false" : "true"
}
})
}
})
6 changes: 6 additions & 0 deletions src/react-components/input-field.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,14 @@ export const InputField = ({
onClick={(e) => {
setVisibility(!visibility)
e.currentTarget.dataset.checked =
e.currentTarget.dataset.checked === "true" ? "false" : "true"
}}
onKeyDown={(e) => {
if (e.key === "Enter" || e.key === " ") {
setVisibility(!visibility)
e.currentTarget.dataset.checked =
e.currentTarget.dataset.checked === "true" ? "false" : "true"
}
}}
data-checked="false"
className={inputFieldVisibilityToggleLabelStyle}
Expand Down

0 comments on commit c892eca

Please sign in to comment.