Clear following PIN fields on reentry

This commit is contained in:
seo
2026-06-17 19:56:23 +09:00
parent db48512585
commit 4499a4d472
2 changed files with 18 additions and 5 deletions
+17 -4
View File
@@ -223,6 +223,8 @@ function showPasswordChangeForm() {
msg.textContent = data.message === 'password_digits_only' ? '암호는 숫자 4자리여야 합니다.' : '현재 암호가 틀립니다.';
if (data.message === 'current_password_invalid') {
currentInput.value = '';
newInput.value = '';
confirmInput.value = '';
currentInput.focus();
}
} catch (_) {
@@ -443,9 +445,20 @@ function createPinKeypad(inputs, onEnter, onActiveChange = null) {
let activeInput = inputs[0];
const keypad = document.createElement('div');
keypad.className = 'launcher-pin-keypad';
const setActiveInput = (input, clear = false) => {
const clearInputsFrom = input => {
const startIndex = inputs.indexOf(input);
if (startIndex < 0) return;
inputs.slice(startIndex).forEach(item => {
item.value = '';
});
};
const setActiveInput = (input, clear = false, clearFollowing = false) => {
activeInput = input;
if (clear) activeInput.value = '';
if (clearFollowing) {
clearInputsFrom(activeInput);
} else if (clear) {
activeInput.value = '';
}
activeInput.focus();
document.querySelectorAll('.launcher-pin-input').forEach(el => el.classList.toggle('active', el === activeInput));
if (typeof onActiveChange === 'function') onActiveChange(activeInput);
@@ -456,7 +469,7 @@ function createPinKeypad(inputs, onEnter, onActiveChange = null) {
if (typeof onActiveChange === 'function') onActiveChange(activeInput);
});
input.addEventListener('click', () => {
setActiveInput(input, input.value.length > 0);
setActiveInput(input, input.value.length > 0, inputs.length > 1 && input.value.length > 0);
});
});
@@ -481,7 +494,7 @@ function createPinKeypad(inputs, onEnter, onActiveChange = null) {
const idx = inputs.indexOf(activeInput);
if (idx >= 0 && idx < inputs.length - 1) {
const nextInput = inputs[idx + 1];
setActiveInput(nextInput, nextInput.value.length > 0);
setActiveInput(nextInput, nextInput.value.length > 0, nextInput.value.length > 0);
} else {
onEnter();
}