checkpoint

This commit is contained in:
rizky 2024-10-25 13:33:30 -07:00
parent 9beea0b93e
commit ce26b706c6
2 changed files with 6 additions and 11 deletions

View File

@ -15,13 +15,6 @@ export const FieldOTP: FC<{
ref: [] as HTMLInputElement[],
});
// useEffect(() => {
// if (typeof fm.data[field.name] === "string") {
// local.otp = fm.data[field.name].split("");
// local.render();
// }
// }, [fm.data[field.name]]);
if (local.otp.length === 0 && digit) {
for (let i = 0; i < digit; i++) {
local.otp.push("");
@ -65,9 +58,13 @@ export const FieldOTP: FC<{
}}
onKeyDown={async (e) => {
if (e.key === "Backspace") {
local.otp[idx] = "";
let _idx = idx;
if (local.otp[_idx].length === 0) {
_idx--;
}
local.otp[_idx] = "";
local.render();
const ref = local.ref[idx - 1];
const ref = local.ref[Math.max(0, _idx - 1)];
if (ref) {
ref.focus();
}

View File

@ -3,8 +3,6 @@ import { useLocal } from "lib/utils/use-local";
import get from "lodash.get";
import { FC, useEffect, useRef } from "react";
import { IMenu, MenuProp } from "./utils/type-menu";
import { LinkParam } from "lib/comps/form/field/type/TypeLink";
import { hashSum } from "lib/utils/hash-sum";
// import { icon } from "../../..";
const local_default = {