Autofocus confirm modal input

This commit is contained in:
Dennis Reimann 2022-06-17 21:31:01 +02:00 committed by Andrew Camilleri
parent bb4a28ecd8
commit 2f1df3be7d

View File

@ -27,7 +27,7 @@
$text.removeAttribute('hidden')
$continue.setAttribute('disabled', 'disabled')
$inputText.textContent = confirmInput
$input.setAttribute("autocomplete", "off");
$input.setAttribute("autocomplete", "off")
$input.addEventListener('input', event => {
event.target.value.trim() === confirmInput
? $continue.removeAttribute('disabled')
@ -38,4 +38,12 @@
$continue.removeAttribute('disabled')
}
});
modal.addEventListener('shown.bs.modal', event => {
const $target = event.relatedTarget
const $input = document.getElementById('ConfirmInput')
const { confirmInput } = $target.dataset
if (confirmInput) {
$input.focus();
}
});
</script>