Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: password input field #133

Merged
merged 4 commits into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
17 changes: 17 additions & 0 deletions src/assets/passwordInput.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright © 2023 Ory Corp
// SPDX-License-Identifier: Apache-2.0

document.getElementsByName("password").forEach((p) => {
if (
p.type === "password" &&
!!(p.offsetWidth || p.offsetHeight || p.getClientRects().length)
Benehiko marked this conversation as resolved.
Show resolved Hide resolved
) {
document.getElementsByName("password").forEach((y) => {
if (y.type === "text") {
y.remove()
}
})
} else if (p.type === "password") {
p.remove()
}
})
15 changes: 14 additions & 1 deletion src/react-components/input-field.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import cn from "classnames"
import { JSX } from "react"
import { JSX, useEffect } from "react"

import {
gridStyle,
Expand Down Expand Up @@ -38,6 +38,19 @@ export const InputField = ({
}: InputFieldProps): JSX.Element => {
const inputId = id ?? useIdWithFallback()

try {
Benehiko marked this conversation as resolved.
Show resolved Hide resolved
useEffect(() => {
const input = document.getElementById(inputId + "-security")
if (input && window.getComputedStyle(input).display !== "none") {
document.getElementById(inputId)?.remove()
} else {
input?.remove()
}
}, [])
} catch (e) {
// ignore (this only affects non-react environments)
}

return (
<div
data-testid={dataTestid}
Expand Down
Loading