Skip to content

Commit 4c97e34

Browse files
authored
fix: pin code delete (#26)
Co-authored-by: zhangfuhao <张福浩>
1 parent 4528e54 commit 4c97e34

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

@sensoro-design/react/src/pin-code/index.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,23 @@ const PinCode = forwardRef<PinCodeRefs, PinCodeProps>(
9292

9393
const code = evt.keyCode || evt.which;
9494
const { tagName, id } = document.activeElement ?? {};
95+
9596
if ([37, 39].includes(code)) {
9697
const operate = code === 37 ? -1 : 1;
9798
const index = tagName === 'INPUT' ? Number(id) + operate : 0;
9899
if (index >= 0 && index < count) {
99100
inputs[index].focus();
100101
}
101102
}
103+
104+
// 删除
105+
if (code === 8 && tagName === 'INPUT') {
106+
setTimeout(() => {
107+
if (Number(id) > 0) {
108+
inputs[Number(id) - 1].focus();
109+
}
110+
}, 0);
111+
}
102112
};
103113

104114
document.addEventListener('keydown', onKeyDown);

0 commit comments

Comments
 (0)