Autofocus confirm modal submit button
So that it can be confirmed with enter
This commit is contained in:
parent
c03ccf94c7
commit
496d75b9ef
|
@ -318,6 +318,7 @@ ready(() => {
|
|||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="${element.className}"
|
||||
autofocus
|
||||
title="${element.title}" data-submit="">
|
||||
${element.dataset.confirm_button_text ?? element.innerHTML}
|
||||
</button>
|
||||
|
@ -328,15 +329,25 @@ ready(() => {
|
|||
`
|
||||
);
|
||||
|
||||
let modal = document.getElementById('confirmation-modal');
|
||||
const modal = document.getElementById('confirmation-modal');
|
||||
modal.addEventListener('hide.bs.modal', () => {
|
||||
modalOpen = false;
|
||||
});
|
||||
modal.querySelector('[data-submit]').addEventListener('click', (event) => {
|
||||
|
||||
const modalSubmitButton = modal.querySelector('[data-submit]');
|
||||
modalSubmitButton.addEventListener('click', () => {
|
||||
element.type = oldType;
|
||||
element.click();
|
||||
});
|
||||
|
||||
/**
|
||||
* After the modal has been shown, focus on the "Submit" button in the modal
|
||||
* so that it can be confirmed with "Enter".
|
||||
*/
|
||||
modal.addEventListener('shown.bs.modal', () => {
|
||||
modalSubmitButton.focus();
|
||||
});
|
||||
|
||||
modalOpen = true;
|
||||
let bootstrapModal = new bootstrap.Modal(modal);
|
||||
bootstrapModal.show();
|
||||
|
|
Loading…
Reference in New Issue