checkpoint
This commit is contained in:
parent
9beea0b93e
commit
ce26b706c6
|
|
@ -15,13 +15,6 @@ export const FieldOTP: FC<{
|
||||||
ref: [] as HTMLInputElement[],
|
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) {
|
if (local.otp.length === 0 && digit) {
|
||||||
for (let i = 0; i < digit; i++) {
|
for (let i = 0; i < digit; i++) {
|
||||||
local.otp.push("");
|
local.otp.push("");
|
||||||
|
|
@ -65,9 +58,13 @@ export const FieldOTP: FC<{
|
||||||
}}
|
}}
|
||||||
onKeyDown={async (e) => {
|
onKeyDown={async (e) => {
|
||||||
if (e.key === "Backspace") {
|
if (e.key === "Backspace") {
|
||||||
local.otp[idx] = "";
|
let _idx = idx;
|
||||||
|
if (local.otp[_idx].length === 0) {
|
||||||
|
_idx--;
|
||||||
|
}
|
||||||
|
local.otp[_idx] = "";
|
||||||
local.render();
|
local.render();
|
||||||
const ref = local.ref[idx - 1];
|
const ref = local.ref[Math.max(0, _idx - 1)];
|
||||||
if (ref) {
|
if (ref) {
|
||||||
ref.focus();
|
ref.focus();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,6 @@ import { useLocal } from "lib/utils/use-local";
|
||||||
import get from "lodash.get";
|
import get from "lodash.get";
|
||||||
import { FC, useEffect, useRef } from "react";
|
import { FC, useEffect, useRef } from "react";
|
||||||
import { IMenu, MenuProp } from "./utils/type-menu";
|
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 "../../..";
|
// import { icon } from "../../..";
|
||||||
|
|
||||||
const local_default = {
|
const local_default = {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue