diff --git a/src/shared/components/common/totp-modal.tsx b/src/shared/components/common/totp-modal.tsx index a2030f84..642491c4 100644 --- a/src/shared/components/common/totp-modal.tsx +++ b/src/shared/components/common/totp-modal.tsx @@ -42,18 +42,28 @@ export default class TotpModal extends Component< constructor(props: TotpModalProps, context: any) { super(props, context); + + this.clearTotp = this.clearTotp.bind(this); } componentDidMount() { document .getElementById("totpModal") ?.addEventListener("shown.bs.modal", focusInput); + + document + .getElementById("totpModal") + ?.addEventListener("hidden.bs.modal", this.clearTotp); } componentWillUnmount() { document .getElementById("totpModal") ?.removeEventListener("shown.bs.modal", focusInput); + + document + .getElementById("totpModal") + ?.removeEventListener("hidden.bs.modal", this.clearTotp); } render() { @@ -96,8 +106,8 @@ export default class TotpModal extends Component< > Enter TOTP -
- {Array(6).map((_, i) => ( +
+ {Array.from(Array(TOTP_LENGTH).keys()).map(i => ( ))} @@ -130,4 +140,9 @@ export default class TotpModal extends Component<
); } + + clearTotp() { + console.log("clearing"); + this.setState({ totp: "" }); + } }